Skip to content
Snippets Groups Projects
Commit 1998266b authored by ko_oler's avatar ko_oler
Browse files

правки по ПР: исправлено условие, поправлены тесты

parent 4ecd6278
Branches
Tags
No related merge requests found
......@@ -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]
......
......@@ -18,7 +18,21 @@ func TestActionURL_New(t *testing.T) {
}{
{
name: "Without action",
want: &URL{},
want: &URL{
URL: &url.URL{
Scheme: "",
Opaque: "",
User: nil,
Host: "",
Path: "",
RawPath: "",
OmitHost: false,
ForceQuery: false,
RawQuery: "",
Fragment: "",
RawFragment: "",
},
},
wantErr: assert.NoError,
},
{
......@@ -114,8 +128,22 @@ func TestActionURL_New(t *testing.T) {
{
name: "With no action id",
action: "grpc:///perxisweb",
want: nil,
wantErr: assert.Error,
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",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment