CloudWatch: Refactor around handleGetRegions (#65713)
* Create minimal EC2 interface * convert regions variable to a function returning a copy * Add test for multiple calls to regions to check regionsCache * Add returns to handler after error * Refactor handleGetRegions
This commit is contained in:
@@ -106,6 +106,20 @@ func (c *fakeCWAnnotationsClient) DescribeAlarms(params *cloudwatch.DescribeAlar
|
||||
return c.describeAlarmsOutput, nil
|
||||
}
|
||||
|
||||
type mockEC2Client struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
func (c *mockEC2Client) DescribeRegions(in *ec2.DescribeRegionsInput) (*ec2.DescribeRegionsOutput, error) {
|
||||
args := c.Called(in)
|
||||
return args.Get(0).(*ec2.DescribeRegionsOutput), args.Error(1)
|
||||
}
|
||||
|
||||
func (c *mockEC2Client) DescribeInstancesPages(in *ec2.DescribeInstancesInput, fn func(*ec2.DescribeInstancesOutput, bool) bool) error {
|
||||
args := c.Called(in, fn)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
type fakeEC2Client struct {
|
||||
ec2iface.EC2API
|
||||
|
||||
|
||||
Reference in New Issue
Block a user