diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2017-06-08 20:41:41 -0400 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2017-06-08 20:41:41 -0400 |
| commit | b580bba092120362867f37a5a691dc8a1fd00d7c (patch) | |
| tree | 3ee722f234107f7a2d5a1054f991ecae0d7d06af /aws/testutils.go | |
| parent | 3837f4874bf8f690bc97d8f83a957804c7ce6783 (diff) | |
Namespacing the AWS funcs
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'aws/testutils.go')
| -rw-r--r-- | aws/testutils.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/aws/testutils.go b/aws/testutils.go index 32c8d408..188dee7a 100644 --- a/aws/testutils.go +++ b/aws/testutils.go @@ -5,6 +5,8 @@ import ( "net/http" "net/http/httptest" "net/url" + + "github.com/aws/aws-sdk-go/service/ec2" ) // MockServer - @@ -24,3 +26,38 @@ func MockServer(code int, body string) (*httptest.Server, *Ec2Meta) { client := &Ec2Meta{server.URL + "/", httpClient, false, make(map[string]string)} return server, client } + +// NewDummyEc2Info - +func NewDummyEc2Info(metaClient *Ec2Meta) *Ec2Info { + i := &Ec2Info{ + metaClient: metaClient, + describer: func() InstanceDescriber { return DummyInstanceDescriber{} }, + } + return i +} + +// NewDummyEc2Meta - +func NewDummyEc2Meta() *Ec2Meta { + return &Ec2Meta{nonAWS: true} +} + +// DummyInstanceDescriber - test doubles +type DummyInstanceDescriber struct { + tags []*ec2.Tag +} + +// DescribeInstances - +func (d DummyInstanceDescriber) DescribeInstances(*ec2.DescribeInstancesInput) (*ec2.DescribeInstancesOutput, error) { + output := &ec2.DescribeInstancesOutput{ + Reservations: []*ec2.Reservation{ + { + Instances: []*ec2.Instance{ + { + Tags: d.tags, + }, + }, + }, + }, + } + return output, nil +} |
