diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index 8f5eb933c923ac615f033d05eb82aafd7a78e735..f9d4d30627596e9e58e7113496df2c9723ed0549 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -22,9 +22,23 @@ func TestActionURL_New(t *testing.T) { wantErr: assert.NoError, }, { - name: "Without deprecated action call", - action: "build-site", - want: &URL{}, + name: "Without deprecated action call", + action: "build-site", + 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,16 +67,41 @@ 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, }, { - name: "With http action", - action: "https://perx.ru", - want: &URL{}, + name: "With http action", + action: "https://perx.ru", + 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 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()") }) } }