forked from ekristen/aws-nuke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoscaling-launch-configurations_mock_test.go
84 lines (64 loc) · 2.11 KB
/
autoscaling-launch-configurations_mock_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
84
package resources
import (
"context"
"testing"
"time"
"github.com/golang/mock/gomock"
"github.com/gotidy/ptr"
"github.com/stretchr/testify/assert"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/ekristen/aws-nuke/v3/mocks/mock_autoscalingiface"
)
func Test_Mock_AutoScalingLaunchConfiguration_List(t *testing.T) {
a := assert.New(t)
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockSvc := mock_autoscalingiface.NewMockAutoScalingAPI(ctrl)
mockSvc.EXPECT().
DescribeLaunchConfigurationsPages(gomock.Eq(&autoscaling.DescribeLaunchConfigurationsInput{}), gomock.Any()).
Do(func(input *autoscaling.DescribeLaunchConfigurationsInput,
fn func(res *autoscaling.DescribeLaunchConfigurationsOutput, lastPage bool) bool) {
fn(&autoscaling.DescribeLaunchConfigurationsOutput{
LaunchConfigurations: []*autoscaling.LaunchConfiguration{
{
LaunchConfigurationName: ptr.String("foo"),
CreatedTime: ptr.Time(time.Now()),
},
},
}, true)
}).
Return(nil)
lister := AutoScalingLaunchConfigurationLister{
mockSvc: mockSvc,
}
resources, err := lister.List(context.TODO(), testListerOpts)
a.Nil(err)
a.Len(resources, 1)
}
func Test_Mock_AutoScalingLaunchConfiguration_Remove(t *testing.T) {
a := assert.New(t)
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockSvc := mock_autoscalingiface.NewMockAutoScalingAPI(ctrl)
mockSvc.EXPECT().DeleteLaunchConfiguration(gomock.Eq(&autoscaling.DeleteLaunchConfigurationInput{
LaunchConfigurationName: ptr.String("foo"),
})).Return(&autoscaling.DeleteLaunchConfigurationOutput{}, nil)
resource := AutoScalingLaunchConfiguration{
svc: mockSvc,
Name: ptr.String("foo"),
}
err := resource.Remove(context.TODO())
a.Nil(err)
}
func Test_Mock_AutoScalingLaunchConfiguration_Properties(t *testing.T) {
a := assert.New(t)
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockSvc := mock_autoscalingiface.NewMockAutoScalingAPI(ctrl)
resource := AutoScalingLaunchConfiguration{
svc: mockSvc,
Name: ptr.String("foo"),
}
properties := resource.Properties()
a.Equal("foo", properties.Get("Name"))
}