Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
jayanthvn committed Aug 2, 2022
1 parent 1707566 commit 82a9803
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions pkg/awsutils/awsutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ func TestAllocIPAddresses(t *testing.T) {
mockEC2.EXPECT().AssignPrivateIpAddressesWithContext(gomock.Any(), input, gomock.Any()).Return(nil, nil)

ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2, instanceType: "c5n.18xlarge"}
err := ins.AllocIPAddresses(eniID, 5)
_, err := ins.AllocIPAddresses(eniID, 5)
assert.NoError(t, err)

// when required IP numbers(50) is higher than ENI's limit(49)
Expand All @@ -597,11 +597,11 @@ func TestAllocIPAddresses(t *testing.T) {
mockEC2.EXPECT().AssignPrivateIpAddressesWithContext(gomock.Any(), input, gomock.Any()).Return(&output, nil)

ins = &EC2InstanceMetadataCache{ec2SVC: mockEC2, instanceType: "c5n.18xlarge"}
err = ins.AllocIPAddresses(eniID, 50)
_, err = ins.AllocIPAddresses(eniID, 50)
assert.NoError(t, err)

// Adding 0 should do nothing
err = ins.AllocIPAddresses(eniID, 0)
_, err = ins.AllocIPAddresses(eniID, 0)
assert.NoError(t, err)
}

Expand All @@ -618,7 +618,7 @@ func TestAllocIPAddressesAlreadyFull(t *testing.T) {
retErr := awserr.New("PrivateIpAddressLimitExceeded", "Too many IPs already allocated", nil)
mockEC2.EXPECT().AssignPrivateIpAddressesWithContext(gomock.Any(), input, gomock.Any()).Return(nil, retErr)
// If EC2 says that all IPs are already attached, we do nothing
err := ins.AllocIPAddresses(eniID, 14)
_, err := ins.AllocIPAddresses(eniID, 14)
assert.NoError(t, err)
}

Expand All @@ -634,11 +634,11 @@ func TestAllocPrefixAddresses(t *testing.T) {
mockEC2.EXPECT().AssignPrivateIpAddressesWithContext(gomock.Any(), input, gomock.Any()).Return(nil, nil)

ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2, instanceType: "c5n.18xlarge", enablePrefixDelegation: true}
err := ins.AllocIPAddresses(eniID, 1)
_, err := ins.AllocIPAddresses(eniID, 1)
assert.NoError(t, err)

// Adding 0 should do nothing
err = ins.AllocIPAddresses(eniID, 0)
_, err = ins.AllocIPAddresses(eniID, 0)
assert.NoError(t, err)
}

Expand All @@ -655,7 +655,7 @@ func TestAllocPrefixesAlreadyFull(t *testing.T) {
retErr := awserr.New("PrivateIpAddressLimitExceeded", "Too many IPs already allocated", nil)
mockEC2.EXPECT().AssignPrivateIpAddressesWithContext(gomock.Any(), input, gomock.Any()).Return(nil, retErr)
// If EC2 says that all IPs are already attached, we do nothing
err := ins.AllocIPAddresses(eniID, 1)
_, err := ins.AllocIPAddresses(eniID, 1)
assert.NoError(t, err)
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/awsutils/mocks/awsutils_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 82a9803

Please sign in to comment.