diff --git a/pkg/action/action.go b/pkg/action/action.go index 98e3e0eca5881714065625bd736777d8c1320fd7..4233d986f5cf0ecd199f64c42b5f6453e0533fce 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -20,7 +20,7 @@ func NewURL(action string) (*URL, error) { } func (u *URL) actionParts() (string, string) { - if u.URL == nil && u.URL.Scheme == "grpc" { + if u.URL != nil && u.URL.Scheme == "grpc" { splitPath := strings.Split(strings.TrimLeft(u.Path, "/"), "/") if len(splitPath) >= 2 { return splitPath[0], splitPath[1] diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index f9d4d30627596e9e58e7113496df2c9723ed0549..0783344048fba0439fff85d6ad508024553e4220 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -17,8 +17,22 @@ func TestActionURL_New(t *testing.T) { wantErr assert.ErrorAssertionFunc }{ { - name: "Without action", - want: &URL{}, + name: "Without action", + want: &URL{ + URL: &url.URL{ + Scheme: "", + Opaque: "", + User: nil, + Host: "", + Path: "", + RawPath: "", + OmitHost: false, + ForceQuery: false, + RawQuery: "", + Fragment: "", + RawFragment: "", + }, + }, wantErr: assert.NoError, }, { @@ -112,10 +126,24 @@ func TestActionURL_New(t *testing.T) { wantErr: assert.Error, }, { - name: "With no action id", - action: "grpc:///perxisweb", - want: nil, - wantErr: assert.Error, + name: "With no action id", + action: "grpc:///perxisweb", + want: &URL{ + URL: &url.URL{ + Scheme: "grpc", + Opaque: "", + User: nil, + Host: "", + Path: "/perxisweb", + RawPath: "", + OmitHost: false, + ForceQuery: false, + RawQuery: "", + Fragment: "", + RawFragment: "", + }, + }, + wantErr: assert.NoError, }, } for _, tt := range tests { @@ -135,6 +163,11 @@ func TestActionURL_String(t *testing.T) { url string want string }{ + { + name: "GRPC action", + url: "grpc:///perxisweb/build-site", + want: "grpc:///perxisweb/build-site", + }, { name: "UI action #1", url: "ui:///space/env/coll",