summaryrefslogtreecommitdiff
path: root/aws
diff options
context:
space:
mode:
authorMarc Boudreau <marc.boudreau@qlik.com>2016-09-06 15:41:52 -0400
committerMarc Boudreau <marc.boudreau@qlik.com>2016-09-06 16:43:42 -0400
commitbbe1a8345c7ce5777429c0b30cf74f62cb1e3f7a (patch)
tree274e8369b78ab0798a99e1085d2400859d1f334d /aws
parent210b6ab675fac3cffd2d2a55bcce6ea71853f385 (diff)
Initializing the metaClient field with NewEc2Meta() instead of with a struct literal
Adding test to cover NewEc2Info function
Diffstat (limited to 'aws')
-rw-r--r--aws/ec2info.go2
-rw-r--r--aws/ec2info_test.go25
2 files changed, 26 insertions, 1 deletions
diff --git a/aws/ec2info.go b/aws/ec2info.go
index 6a8d1b4a..8b9ab2ad 100644
--- a/aws/ec2info.go
+++ b/aws/ec2info.go
@@ -20,7 +20,7 @@ type InstanceDescriber interface {
// NewEc2Info -
func NewEc2Info() *Ec2Info {
- metaClient := &Ec2Meta{}
+ metaClient := NewEc2Meta()
return &Ec2Info{
describer: func() InstanceDescriber {
region := metaClient.Region()
diff --git a/aws/ec2info_test.go b/aws/ec2info_test.go
index 1aac1907..14ca655c 100644
--- a/aws/ec2info_test.go
+++ b/aws/ec2info_test.go
@@ -98,3 +98,28 @@ func TestTag_NonEC2(t *testing.T) {
assert.Equal(t, "", e.Tag("foo"))
assert.Equal(t, "default", e.Tag("foo", "default"))
}
+
+func TestNewEc2Info(t *testing.T) {
+ server, ec2meta := MockServer(200, `"i-1234"`)
+ defer server.Close()
+ client := DummyInstanceDescriber{
+ tags: []*ec2.Tag{
+ &ec2.Tag{
+ Key: aws.String("foo"),
+ Value: aws.String("bar"),
+ },
+ &ec2.Tag{
+ Key: aws.String("baz"),
+ Value: aws.String("qux"),
+ },
+ },
+ }
+ e := NewEc2Info()
+ e.describer = func() InstanceDescriber {
+ return client
+ }
+ e.metaClient = ec2meta
+
+ assert.Equal(t, "bar", e.Tag("foo"))
+ assert.Equal(t, "bar", e.Tag("foo", "default"))
+}