Skip to content
Snippets Groups Projects
Commit 17629222 authored by Pavel Antonov's avatar Pavel Antonov :asterisk:
Browse files

Merge remote-tracking branch 'origin/feature/PRXS-1609-AddURLStruct' into...

Merge remote-tracking branch 'origin/feature/PRXS-1609-AddURLStruct' into feature/PRXS-1609-AddURLStruct

# Conflicts:
#	pkg/action/action.go
parents 4f0be128 0ca3f2f7
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,21 @@ func TestActionURL_New(t *testing.T) { ...@@ -24,7 +24,21 @@ func TestActionURL_New(t *testing.T) {
{ {
name: "Without deprecated action call", name: "Without deprecated action call",
action: "build-site", action: "build-site",
want: &URL{}, want: &URL{
URL: &url.URL{
Scheme: "",
Opaque: "",
User: nil,
Host: "",
Path: "build-site",
RawPath: "",
OmitHost: false,
ForceQuery: false,
RawQuery: "",
Fragment: "",
RawFragment: "",
},
},
url: "build-site", url: "build-site",
wantErr: assert.NoError, wantErr: assert.NoError,
}, },
...@@ -32,8 +46,19 @@ func TestActionURL_New(t *testing.T) { ...@@ -32,8 +46,19 @@ func TestActionURL_New(t *testing.T) {
name: "With grpc action", name: "With grpc action",
action: "grpc:///perxisweb/build-site", action: "grpc:///perxisweb/build-site",
want: &URL{ want: &URL{
id: "build-site", URL: &url.URL{
extension: "perxisweb", Scheme: "grpc",
Opaque: "",
User: nil,
Host: "",
Path: "/perxisweb/build-site",
RawPath: "",
OmitHost: false,
ForceQuery: false,
RawQuery: "",
Fragment: "",
RawFragment: "",
},
}, },
url: "grpc:///perxisweb/build-site", url: "grpc:///perxisweb/build-site",
wantErr: assert.NoError, wantErr: assert.NoError,
...@@ -42,8 +67,19 @@ func TestActionURL_New(t *testing.T) { ...@@ -42,8 +67,19 @@ func TestActionURL_New(t *testing.T) {
name: "With ui action", name: "With ui action",
action: "ui:///space/env/coll", action: "ui:///space/env/coll",
want: &URL{ want: &URL{
id: "", URL: &url.URL{
extension: "", Scheme: "ui",
Opaque: "",
User: nil,
Host: "",
Path: "/space/env/coll",
RawPath: "",
OmitHost: false,
ForceQuery: false,
RawQuery: "",
Fragment: "",
RawFragment: "",
},
}, },
url: "ui:///space/env/coll", url: "ui:///space/env/coll",
wantErr: assert.NoError, wantErr: assert.NoError,
...@@ -51,7 +87,21 @@ func TestActionURL_New(t *testing.T) { ...@@ -51,7 +87,21 @@ func TestActionURL_New(t *testing.T) {
{ {
name: "With http action", name: "With http action",
action: "https://perx.ru", action: "https://perx.ru",
want: &URL{}, want: &URL{
URL: &url.URL{
Scheme: "https",
Opaque: "",
User: nil,
Host: "perx.ru",
Path: "",
RawPath: "",
OmitHost: false,
ForceQuery: false,
RawQuery: "",
Fragment: "",
RawFragment: "",
},
},
url: "https://perx.ru", url: "https://perx.ru",
wantErr: assert.NoError, wantErr: assert.NoError,
}, },
...@@ -70,9 +120,6 @@ func TestActionURL_New(t *testing.T) { ...@@ -70,9 +120,6 @@ func TestActionURL_New(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
if tt.url != "" {
tt.want.URL, _ = url.Parse(tt.url)
}
got, err := NewURL(tt.action) got, err := NewURL(tt.action)
if !tt.wantErr(t, err, fmt.Sprintf("NewURL(%v)", tt.action)) { if !tt.wantErr(t, err, fmt.Sprintf("NewURL(%v)", tt.action)) {
return return
...@@ -82,51 +129,37 @@ func TestActionURL_New(t *testing.T) { ...@@ -82,51 +129,37 @@ func TestActionURL_New(t *testing.T) {
} }
} }
func TestActionURL_Make(t *testing.T) { func TestActionURL_String(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
id string
extension string
url string url string
want string want string
}{ }{
{ {
name: "Without action and extensions id's #1", name: "UI action #1",
url: "grpc:///extension-id/action-id",
want: "grpc:///extension-id/action-id",
},
{
name: "Without action and extensions id's #2",
url: "ui:///space/env/coll", url: "ui:///space/env/coll",
want: "ui:///space/env/coll", want: "ui:///space/env/coll",
}, },
{ {
name: "Without action and extensions id's #3", name: "UI action deprecated call #2",
url: "space/env/coll", url: "space/env/coll",
want: "space/env/coll", want: "space/env/coll",
}, },
{ {
name: "Without action and extensions id's #4", name: "Https action",
url: "https://perx.ru", url: "https://perx.ru",
want: "https://perx.ru", want: "https://perx.ru",
}, },
{ {
name: "With action and extensions", name: "With action deprecated call",
id: "action-id", url: "extension-id",
extension: "extension-id", want: "extension-id",
want: "grpc:///extension-id/action-id",
}, },
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
p := &URL{ p, _ := NewURL(tt.url)
id: tt.id, assert.Equalf(t, tt.want, p.String(), "String()")
extension: tt.extension,
}
if tt.url != "" {
p.URL, _ = url.Parse(tt.url)
}
assert.Equalf(t, tt.want, p.MakeURL(), "MakeFromURL()")
}) })
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment