Select Git revision
action_test.go 2.70 KiB
package action
import (
"fmt"
"net/url"
"testing"
"github.com/stretchr/testify/assert"
)
func TestActionURL_New(t *testing.T) {
tests := []struct {
name string
action string
want *URL
url string
wantErr assert.ErrorAssertionFunc
}{
{
name: "Without action",
want: &URL{},
wantErr: assert.NoError,
},
{
name: "Without deprecated action call",
action: "build-site",
want: &URL{},
url: "build-site",
wantErr: assert.NoError,
},
{
name: "With grpc action",
action: "grpc:///perxisweb/build-site",
want: &URL{
id: "build-site",
extension: "perxisweb",
},
url: "grpc:///perxisweb/build-site",
wantErr: assert.NoError,
},
{
name: "With ui action",
action: "ui:///space/env/coll",
want: &URL{
id: "",
extension: "",
},
url: "ui:///space/env/coll",
wantErr: assert.NoError,
},
{
name: "With http action",
action: "https://perx.ru",
want: &URL{},
url: "https://perx.ru",
wantErr: assert.NoError,
},
{
name: "With error in parse",
action: "grpc://user:abc{DEf1=ghi@example.com:5432/db?sslmode=require",
want: nil,
wantErr: assert.Error,
},
{
name: "With no action id",
action: "grpc:///perxisweb",
want: nil,
wantErr: assert.Error,
},
}