From 1998266b8c9e803d8bc3caa0d19fdbf40bc49045 Mon Sep 17 00:00:00 2001 From: ko_oler <kooler89@gmail.com> Date: Mon, 2 Oct 2023 11:28:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D0=9F=D0=A0:=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=BE=20=D1=83=D1=81=D0=BB=D0=BE=D0=B2=D0=B8?= =?UTF-8?q?=D0=B5,=20=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D1=82=D0=B5=D1=81=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/action/action.go | 2 +- pkg/action/action_test.go | 45 +++++++++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 98e3e0ec..4233d986 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 f9d4d306..07833440 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", -- GitLab