Skip to content
Snippets Groups Projects
Select Git revision
  • a978cfa2b8e69ef9b4be4b83d5a7c393f7521815
  • master default protected
  • refactor/PRXS-3053-Files
  • feature/3149-LocaleCodeAsID-Feature
  • feature/PRXS-3383-CollectionsSort
  • feature/PRXS-3143-3235-ReferenceOptions
  • feature/PRXS-3421-ImplementNewRefAPI
  • feature/PRXS-3143-LimitReferenceFields
  • feature/PRXS-3234-FeaturePruneIdents
  • PRXS-3421-RecursiveReferences
  • feature/3109-SerializeFeature
  • release/0.33
  • feature/3109-RecoverySchema
  • feature/3109-feature
  • fix/PRXS-3369-ValidateFields
  • refactor/PRXS-3306-MovePkgGroup1
  • refactor/6-pkg-refactor-expr
  • fix/PRXS-3360-TemplateBuilderPatch
  • feature/3293-MongoV2
  • feature/3272-GoVersionUp
  • feature/PRXS-3218-HideTemplateActions
  • v0.33.1
  • v0.32.0
  • v0.31.1
  • v0.31.0
  • v0.30.0
  • v0.29.0
  • v0.28.0
  • v0.27.0-alpha.1+16
  • v0.27.0-alpha.1+15
  • v0.27.0-alpha.1+14
  • v0.27.0-alpha.1+13
  • v0.27.0-alpha.1+12
  • v0.27.0-alpha.1+11
  • v0.27.0-alpha.1+10
  • v0.27.0-alpha.1+9
  • v0.27.0-alpha.1+8
  • v0.27.0-alpha.1+7
  • v0.27.0-alpha.1+6
  • v0.27.0-alpha.1+5
  • v0.27.0-alpha.1+4
41 results

extension.go

Blame
  • action_url_test.go 1.79 KiB
    package extension
    
    import (
    	"fmt"
    	"net/url"
    	"testing"
    
    	"github.com/stretchr/testify/assert"
    )
    
    func TestNewActionURL(t *testing.T) {
    	tests := []struct {
    		name    string
    		action  string
    		want    *ActionURL
    		url     string
    		wantErr assert.ErrorAssertionFunc
    	}{
    		{
    			name:    "Without action",
    			want:    &ActionURL{},
    			wantErr: assert.NoError,
    		},
    		{
    			name:   "Without deprecated action call",
    			action: "build-site",
    			want: &ActionURL{
    				actionURL: "build-site",
    			},
    			url:     "build-site",
    			wantErr: assert.NoError,
    		},
    		{
    			name:   "With grpc action",
    			action: "grpc:///perxisweb/build-site",
    			want: &ActionURL{
    				actionURL: "grpc:///perxisweb/build-site",
    				actionID:  "build-site",
    				extension: "perxisweb",
    				scheme:    "grpc",
    			},
    			url:     "grpc:///perxisweb/build-site",
    			wantErr: assert.NoError,
    		},
    		{
    			name:   "With ui action",
    			action: "ui:///space/env/coll",
    			want: &ActionURL{
    				actionURL: "ui:///space/env/coll",
    				actionID:  "",
    				extension: "",
    				scheme:    "ui",
    			},
    			url:     "ui:///space/env/coll",
    			wantErr: assert.NoError,
    		},
    		{
    			name:   "With http action",
    			action: "https://perx.ru",
    			want: &ActionURL{
    				actionURL: "https://perx.ru",
    				scheme:    "https",
    			},
    			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,
    		},
    	}
    	for _, tt := range tests {
    		t.Run(tt.name, func(t *testing.T) {
    			if tt.url != "" {
    				tt.want.url, _ = url.Parse(tt.url)
    			}
    			got, err := NewActionURL(tt.action)
    			if !tt.wantErr(t, err, fmt.Sprintf("NewActionURL(%v)", tt.action)) {
    				return
    			}
    			assert.Equalf(t, tt.want, got, "NewActionURL(%v)", tt.action)
    		})
    	}
    }