-
Notifications
You must be signed in to change notification settings - Fork 1
/
externals_test.go
83 lines (79 loc) · 1.63 KB
/
externals_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package kanvas
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestAWSParamURL(t *testing.T) {
cases := []struct {
name string
p AWSParam
want string
}{
{
name: "simple",
p: AWSParam{
Path: "foo",
},
want: "ref+awsssm://foo",
},
{
name: "with subpath",
p: AWSParam{
Path: "foo",
SubPath: "bar",
},
want: "ref+awsssm://foo#/bar",
},
{
name: "with region",
p: AWSParam{
Path: "foo",
Region: "us-east-1",
},
want: "ref+awsssm://foo?region=us-east-1",
},
{
name: "with profile",
p: AWSParam{
Path: "foo",
Profile: "default",
},
want: "ref+awsssm://foo?profile=default",
},
{
name: "with role arn",
p: AWSParam{
Path: "foo",
RoleARN: "arn:aws:iam::123456789012:role/MyRole",
},
want: "ref+awsssm://foo?role_arn=arn:aws:iam::123456789012:role/MyRole",
},
{
name: "everything except subpath",
p: AWSParam{
Path: "foo",
Region: "us-east-1",
Profile: "default",
RoleARN: "arn:aws:iam::123456789012:role/MyRole",
},
want: "ref+awsssm://foo?region=us-east-1&profile=default&role_arn=arn:aws:iam::123456789012:role/MyRole",
},
{
name: "everything",
p: AWSParam{
Path: "foo",
SubPath: "bar",
Region: "us-east-1",
Profile: "default",
RoleARN: "arn:aws:iam::123456789012:role/MyRole",
},
want: "ref+awsssm://foo?region=us-east-1&profile=default&role_arn=arn:aws:iam::123456789012:role/MyRole#/bar",
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got := tc.p.ValsRefURL()
require.Equal(t, tc.want, got)
})
}
}