Skip to content
Snippets Groups Projects
Commit 7e09f8e9 authored by ko_oler's avatar ko_oler
Browse files

fix

parent ddab0de7
No related branches found
No related tags found
No related merge requests found
......@@ -8,16 +8,16 @@ import (
"git.perx.ru/perxis/perxis-go/pkg/errors"
)
// Url структура для хранения данных о переданном действии.
type Url struct {
// URL структура для хранения данных о переданном действии.
type URL struct {
id string
extension string
*url.URL
}
// NewUrl возвращает структуру ActionURL
func NewUrl(action string) (*Url, error) {
actionURL := &Url{}
// NewURL возвращает структуру ActionURL
func NewURL(action string) (*URL, error) {
actionURL := &URL{}
if action == "" {
return actionURL, nil
......@@ -43,28 +43,28 @@ func NewUrl(action string) (*Url, error) {
return actionURL, nil
}
// ID возвращает сохраненный в Url id действия
func (u *Url) ID() string {
// ID возвращает сохраненный в URL id действия
func (u *URL) ID() string {
return u.id
}
// SetID устанавливает в Url id действия
func (u *Url) SetID(id string) {
// SetID устанавливает в URL id действия
func (u *URL) SetID(id string) {
u.id = id
}
// Extension возвращает сохраненный в Url id расширения
func (u *Url) Extension() string {
// Extension возвращает сохраненный в URL id расширения
func (u *URL) Extension() string {
return u.extension
}
// SetExtension устанавливает в Url id расширения
func (u *Url) SetExtension(ext string) {
// SetExtension устанавливает в URL id расширения
func (u *URL) SetExtension(ext string) {
u.extension = ext
}
// SetURL устанавливает структуру URL
func (u *Url) SetURL(s string) (err error) {
func (u *URL) SetURL(s string) (err error) {
if u.URL, err = url.Parse(s); err != nil {
return err
}
......@@ -72,7 +72,7 @@ func (u *Url) SetURL(s string) (err error) {
}
// Make возвращает Action URL из сохраненных данных
func (u *Url) Make() string {
func (u *URL) Make() string {
if u.id != "" && u.extension != "" {
return fmt.Sprintf("grpc:///%s/%s", u.extension, u.id)
}
......
......@@ -12,26 +12,26 @@ func TestActionURL_New(t *testing.T) {
tests := []struct {
name string
action string
want *Url
want *URL
url string
wantErr assert.ErrorAssertionFunc
}{
{
name: "Without action",
want: &Url{},
want: &URL{},
wantErr: assert.NoError,
},
{
name: "Without deprecated action call",
action: "build-site",
want: &Url{},
want: &URL{},
url: "build-site",
wantErr: assert.NoError,
},
{
name: "With grpc action",
action: "grpc:///perxisweb/build-site",
want: &Url{
want: &URL{
id: "build-site",
extension: "perxisweb",
},
......@@ -41,7 +41,7 @@ func TestActionURL_New(t *testing.T) {
{
name: "With ui action",
action: "ui:///space/env/coll",
want: &Url{
want: &URL{
id: "",
extension: "",
},
......@@ -51,7 +51,7 @@ func TestActionURL_New(t *testing.T) {
{
name: "With http action",
action: "https://perx.ru",
want: &Url{},
want: &URL{},
url: "https://perx.ru",
wantErr: assert.NoError,
},
......@@ -73,11 +73,11 @@ func TestActionURL_New(t *testing.T) {
if tt.url != "" {
tt.want.URL, _ = url.Parse(tt.url)
}
got, err := NewUrl(tt.action)
if !tt.wantErr(t, err, fmt.Sprintf("NewUrl(%v)", tt.action)) {
got, err := NewURL(tt.action)
if !tt.wantErr(t, err, fmt.Sprintf("NewURL(%v)", tt.action)) {
return
}
assert.Equalf(t, tt.want, got, "NewUrl(%v)", tt.action)
assert.Equalf(t, tt.want, got, "NewURL(%v)", tt.action)
})
}
}
......@@ -119,7 +119,7 @@ func TestActionURL_Make(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := &Url{
p := &URL{
id: tt.id,
extension: tt.extension,
}
......
......@@ -83,7 +83,7 @@ func (srv *Server) Update(ctx context.Context, request *UpdateRequest) (*UpdateR
func (srv *Server) Action(ctx context.Context, in *pb.ActionRequest) (*pb.ActionResponse, error) {
ext := in.Extension
if ext == "" {
actionURL, err := action.NewUrl(in.Action)
actionURL, err := action.NewURL(in.Action)
if err != nil {
return nil, err
}
......
......@@ -158,7 +158,7 @@ func (s *Extension) Uninstall(ctx context.Context, in *extension.UninstallReques
func (s *Extension) Action(ctx context.Context, in *extension.ActionRequest) (*extension.ActionResponse, error) {
ext := in.Extension
if ext == "" {
actionURL, err := action.NewUrl(in.Action)
actionURL, err := action.NewURL(in.Action)
if err != nil {
return nil, err
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment