forked from ekristen/aws-nuke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec2-instance_mock_test.go
37 lines (31 loc) · 957 Bytes
/
ec2-instance_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
package resources
import (
"testing"
"time"
"github.com/gotidy/ptr"
"github.com/stretchr/testify/assert"
"github.com/aws/aws-sdk-go/service/ec2"
)
func Test_Mock_EC2Instance_Properties(t *testing.T) {
now := time.Now().UTC()
r := &EC2Instance{
ID: ptr.String("instanceID"),
ImageID: ptr.String("imageID"),
State: ptr.String("state"),
InstanceType: ptr.String("instanceType"),
LaunchTime: ptr.Time(now),
Tags: []*ec2.Tag{
{
Key: ptr.String("key"),
Value: ptr.String("value"),
},
},
}
properties := r.Properties()
assert.Equal(t, "instanceID", properties.Get("Identifier"))
assert.Equal(t, "imageID", properties.Get("ImageIdentifier"))
assert.Equal(t, "state", properties.Get("InstanceState"))
assert.Equal(t, "instanceType", properties.Get("InstanceType"))
assert.Equal(t, now.Format(time.RFC3339), properties.Get("LaunchTime"))
assert.Equal(t, "value", properties.Get("tag:key"))
}