/
aws-mocks.go
83 lines (71 loc) · 3.25 KB
/
aws-mocks.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
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license" file accompanying this file. This file is distributed
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License
package test
import (
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/aws/aws-sdk-go/service/autoscaling/autoscalingiface"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
"github.com/aws/aws-sdk-go/service/sqs"
"github.com/aws/aws-sdk-go/service/sqs/sqsiface"
)
// MockedSQS mocks the SQS API
type MockedSQS struct {
sqsiface.SQSAPI
ReceiveMessageResp sqs.ReceiveMessageOutput
ReceiveMessageErr error
DeleteMessageResp sqs.DeleteMessageOutput
DeleteMessageErr error
}
// ReceiveMessage mocks the sqs.ReceiveMessage API call
func (m MockedSQS) ReceiveMessage(input *sqs.ReceiveMessageInput) (*sqs.ReceiveMessageOutput, error) {
return &m.ReceiveMessageResp, m.ReceiveMessageErr
}
// DeleteMessage mocks the sqs.DeleteMessage API call
func (m MockedSQS) DeleteMessage(input *sqs.DeleteMessageInput) (*sqs.DeleteMessageOutput, error) {
return &m.DeleteMessageResp, m.DeleteMessageErr
}
// MockedEC2 mocks the EC2 API
type MockedEC2 struct {
ec2iface.EC2API
DescribeInstancesResp ec2.DescribeInstancesOutput
DescribeInstancesErr error
}
// DescribeInstances mocks the ec2.DescribeInstances API call
func (m MockedEC2) DescribeInstances(input *ec2.DescribeInstancesInput) (*ec2.DescribeInstancesOutput, error) {
return &m.DescribeInstancesResp, m.DescribeInstancesErr
}
// MockedASG mocks the autoscaling API
type MockedASG struct {
autoscalingiface.AutoScalingAPI
CompleteLifecycleActionResp autoscaling.CompleteLifecycleActionOutput
CompleteLifecycleActionErr error
DescribeAutoScalingInstancesResp autoscaling.DescribeAutoScalingInstancesOutput
DescribeAutoScalingInstancesErr error
DescribeTagsPagesResp autoscaling.DescribeTagsOutput
DescribeTagsPagesErr error
}
// CompleteLifecycleAction mocks the autoscaling.CompleteLifecycleAction API call
func (m MockedASG) CompleteLifecycleAction(input *autoscaling.CompleteLifecycleActionInput) (*autoscaling.CompleteLifecycleActionOutput, error) {
return &m.CompleteLifecycleActionResp, m.CompleteLifecycleActionErr
}
// DescribeAutoScalingInstances mocks the autoscaling.DescribeAutoScalingInstances API call
func (m MockedASG) DescribeAutoScalingInstances(input *autoscaling.DescribeAutoScalingInstancesInput) (*autoscaling.DescribeAutoScalingInstancesOutput, error) {
return &m.DescribeAutoScalingInstancesResp, m.DescribeAutoScalingInstancesErr
}
type describeTagsPagesFn = func(page *autoscaling.DescribeTagsOutput, lastPage bool) bool
// DescribeTagsPages mocks the autoscaling.DescribeTagsPages API call
func (m MockedASG) DescribeTagsPages(input *autoscaling.DescribeTagsInput, fn describeTagsPagesFn) error {
fn(&m.DescribeTagsPagesResp, true)
return m.DescribeTagsPagesErr
}