forked from ekristen/aws-nuke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudcontrol_test.go
41 lines (36 loc) · 1.03 KB
/
cloudcontrol_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
package resources
import (
"testing"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)
func TestCloudControlParseProperties(t *testing.T) {
logrus.SetLevel(logrus.DebugLevel)
cases := []struct {
name string
payload string
want []string
}{
{
name: "ActualEC2VPC",
payload: `{"VpcId":"vpc-456","InstanceTenancy":"default","CidrBlockAssociations":["vpc-cidr-assoc-1234", "vpc-cidr-assoc-5678"],"CidrBlock":"10.10.0.0/16","Tags":[{"Value":"Kubernetes VPC","Key":"Name"}]}`, //nolint:lll
want: []string{
`CidrBlock: "10.10.0.0/16"`,
`Tags.["Name"]: "Kubernetes VPC"`,
`VpcId: "vpc-456"`,
`InstanceTenancy: "default"`,
`CidrBlockAssociations.["vpc-cidr-assoc-1234"]: "true"`,
`CidrBlockAssociations.["vpc-cidr-assoc-5678"]: "true"`,
},
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
result, err := cloudControlParseProperties(tc.payload)
assert.NoError(t, err)
for _, w := range tc.want {
assert.Contains(t, result.String(), w)
}
})
}
}