Skip to content

Commit 66c1cb3

Browse files
committed
fix(test): avoid mutex copy in TestFindOfferingID_OfferingClassReachesSDKCall
Construct capturingMockEC2Client directly instead of copying *MockEC2Client to silence the go vet copylocks warning (MockEC2Client embeds mock.Mock which contains sync.Mutex).
1 parent db8203c commit 66c1cb3

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎providers/aws/services/ec2/client_test.go‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -955,11 +955,10 @@ func TestFindOfferingID_OfferingClassReachesSDKCall(t *testing.T) {
955955
t.Run(tc.name, func(t *testing.T) {
956956
t.Parallel()
957957

958-
inner := &MockEC2Client{}
959-
inner.On("DescribeReservedInstancesOfferings", mock.Anything, mock.Anything).
958+
cap := &capturingMockEC2Client{}
959+
cap.On("DescribeReservedInstancesOfferings", mock.Anything, mock.Anything).
960960
Return(offeringOutput, nil).Once()
961961

962-
cap := &capturingMockEC2Client{MockEC2Client: *inner}
963962
client := &Client{client: cap, region: "us-east-1"}
964963

965964
id, err := client.findOfferingID(context.Background(), rec, "", tc.offeringClassStr)
@@ -970,7 +969,7 @@ func TestFindOfferingID_OfferingClassReachesSDKCall(t *testing.T) {
970969
assert.Equal(t, tc.wantOfferingClass, cap.LastDescribeOfferingsInput.OfferingClass,
971970
"OfferingClass on the SDK call must match the configured value")
972971
}
973-
inner.AssertExpectations(t)
972+
cap.AssertExpectations(t)
974973
})
975974
}
976975
}

0 commit comments

Comments
 (0)