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