From 7452cb2c4f80f094e621b4a475eadf311e666df7 Mon Sep 17 00:00:00 2001 From: Nathan LeClaire Date: Fri, 4 Mar 2016 12:20:27 -0800 Subject: [PATCH] Fix amazonec2 test nitpicks Signed-off-by: Nathan LeClaire --- drivers/amazonec2/stub_test.go | 36 ++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/drivers/amazonec2/stub_test.go b/drivers/amazonec2/stub_test.go index 3d4b540763..f4b1a4dc37 100644 --- a/drivers/amazonec2/stub_test.go +++ b/drivers/amazonec2/stub_test.go @@ -96,28 +96,34 @@ type fakeEC2SecurityGroupTestRecorder struct { mock.Mock } -func (f *fakeEC2SecurityGroupTestRecorder) DescribeSecurityGroups( - input *ec2.DescribeSecurityGroupsInput) (*ec2.DescribeSecurityGroupsOutput, error) { - +func (f *fakeEC2SecurityGroupTestRecorder) DescribeSecurityGroups(input *ec2.DescribeSecurityGroupsInput) (*ec2.DescribeSecurityGroupsOutput, error) { result := f.Called(input) - value, _ := result.Get(0).(*ec2.DescribeSecurityGroupsOutput) - return value, result.Error(1) + err := result.Error(1) + value, ok := result.Get(0).(*ec2.DescribeSecurityGroupsOutput) + if !ok && err == nil { + return nil, errors.New("Type assertion to DescribeSecurityGroupsOutput failed") + } + return value, err } -func (f *fakeEC2SecurityGroupTestRecorder) CreateSecurityGroup( - input *ec2.CreateSecurityGroupInput) (*ec2.CreateSecurityGroupOutput, error) { - +func (f *fakeEC2SecurityGroupTestRecorder) CreateSecurityGroup(input *ec2.CreateSecurityGroupInput) (*ec2.CreateSecurityGroupOutput, error) { result := f.Called(input) - value, _ := result.Get(0).(*ec2.CreateSecurityGroupOutput) - return value, result.Error(1) + err := result.Error(1) + value, ok := result.Get(0).(*ec2.CreateSecurityGroupOutput) + if !ok && err == nil { + return nil, errors.New("Type assertion to CreateSecurityGroupOutput failed") + } + return value, err } -func (f *fakeEC2SecurityGroupTestRecorder) AuthorizeSecurityGroupIngress( - input *ec2.AuthorizeSecurityGroupIngressInput) (*ec2.AuthorizeSecurityGroupIngressOutput, error) { - +func (f *fakeEC2SecurityGroupTestRecorder) AuthorizeSecurityGroupIngress(input *ec2.AuthorizeSecurityGroupIngressInput) (*ec2.AuthorizeSecurityGroupIngressOutput, error) { result := f.Called(input) - value, _ := result.Get(0).(*ec2.AuthorizeSecurityGroupIngressOutput) - return value, result.Error(1) + err := result.Error(1) + value, ok := result.Get(0).(*ec2.AuthorizeSecurityGroupIngressOutput) + if !ok && err == nil { + return nil, errors.New("Type assertion to AuthorizeSecurityGroupIngressInput failed") + } + return value, err } func NewTestDriver() *Driver {