-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugins_test.go
74 lines (67 loc) · 1.33 KB
/
plugins_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
package pipeline
import (
"encoding/json"
"testing"
"github.com/google/go-cmp/cmp"
)
func TestPluginsUnmarshalJSON(t *testing.T) {
t.Parallel()
src := []byte(`[
{
"xxx/aws-assume-role#v0.1.0": {
"role": "arn:aws:iam::xxx:role/xxx"
}
},
{
"ecr#v1.1.4": {
"account_ids": "xxx",
"login": true,
"registry_region": "us-east-1"
}
},
{
"docker-compose#v2.5.1": {
"config": ".buildkite/docker/docker-compose.yml",
"env": [
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY",
"AWS_SESSION_TOKEN"
],
"run": "xxx"
}
}
]`)
var got Plugins
if err := json.Unmarshal(src, &got); err != nil {
t.Fatalf("json.Unmarshal(%q, &got) = %v", src, err)
}
want := Plugins{
{
Source: "xxx/aws-assume-role#v0.1.0",
Config: map[string]any{"role": "arn:aws:iam::xxx:role/xxx"},
},
{
Source: "ecr#v1.1.4",
Config: map[string]any{
"login": true,
"account_ids": "xxx",
"registry_region": "us-east-1",
},
},
{
Source: "docker-compose#v2.5.1",
Config: map[string]any{
"run": "xxx",
"config": ".buildkite/docker/docker-compose.yml",
"env": []any{
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY",
"AWS_SESSION_TOKEN",
},
},
},
}
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unmarshaled Plugin diff (-got +want):\n%s", diff)
}
}