Skip to content

Commit

Permalink
Merge pull request #62 from marcboudreau/fixing-panic-in-ec2info
Browse files Browse the repository at this point in the history
Fixing a panic in Ec2Info.go
  • Loading branch information
hairyhenderson authored Sep 6, 2016
2 parents 210b6ab + bbe1a83 commit f0f19cd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aws/ec2info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type InstanceDescriber interface {

// NewEc2Info -
func NewEc2Info() *Ec2Info {
metaClient := &Ec2Meta{}
metaClient := NewEc2Meta()
return &Ec2Info{
describer: func() InstanceDescriber {
region := metaClient.Region()
Expand Down
25 changes: 25 additions & 0 deletions aws/ec2info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}

0 comments on commit f0f19cd

Please sign in to comment.