forked from ekristen/aws-nuke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudformation-type_test.go
67 lines (58 loc) · 1.87 KB
/
cloudformation-type_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
package resources
import (
"context"
"testing"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudformation"
"github.com/ekristen/aws-nuke/v3/mocks/mock_cloudformationiface"
)
func TestCloudformationType_Remove(t *testing.T) {
a := assert.New(t)
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockCloudformation := mock_cloudformationiface.NewMockCloudFormationAPI(ctrl)
cfnType := CloudFormationType{
svc: mockCloudformation,
typeSummary: &cloudformation.TypeSummary{
TypeArn: aws.String("foobar"),
},
}
mockCloudformation.EXPECT().ListTypeVersions(gomock.Eq(&cloudformation.ListTypeVersionsInput{
Arn: aws.String("foobar"),
})).Return(&cloudformation.ListTypeVersionsOutput{
TypeVersionSummaries: []*cloudformation.TypeVersionSummary{
{
IsDefaultVersion: aws.Bool(true),
VersionId: aws.String("1"),
TypeName: aws.String("t1"),
Type: aws.String("RESOURCE"),
},
},
NextToken: aws.String("nextToken"),
}, nil)
mockCloudformation.EXPECT().ListTypeVersions(gomock.Eq(&cloudformation.ListTypeVersionsInput{
Arn: aws.String("foobar"),
NextToken: aws.String("nextToken"),
})).Return(&cloudformation.ListTypeVersionsOutput{
TypeVersionSummaries: []*cloudformation.TypeVersionSummary{
{
IsDefaultVersion: aws.Bool(false),
VersionId: aws.String("2"),
TypeName: aws.String("t2"),
Type: aws.String("RESOURCE"),
},
},
}, nil)
mockCloudformation.EXPECT().DeregisterType(&cloudformation.DeregisterTypeInput{
VersionId: aws.String("2"),
TypeName: aws.String("t2"),
Type: aws.String("RESOURCE"),
})
mockCloudformation.EXPECT().DeregisterType(&cloudformation.DeregisterTypeInput{
Arn: aws.String("foobar"),
})
err := cfnType.Remove(context.TODO())
a.Nil(err)
}