Skip to content

Commit 386ecd1

Browse files
committed
address linter issues
1 parent efe03c1 commit 386ecd1

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

cni/network/invoker_mock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func NewMockIpamInvoker(ipv6, v4Fail, v6Fail, delegatedVMNIC, delegatedVMNICFail
4747

4848
func NewCustomMockIpamInvoker(customReturn map[string]network.InterfaceInfo) *MockIpamInvoker {
4949
return &MockIpamInvoker{
50-
add: func(opt IPAMAddConfig) (ipamAddResult IPAMAddResult, err error) {
50+
add: func(_ IPAMAddConfig) (ipamAddResult IPAMAddResult, err error) {
5151
ipamAddResult = IPAMAddResult{interfaceInfo: make(map[string]network.InterfaceInfo)}
5252
ipamAddResult.interfaceInfo = customReturn
5353
return ipamAddResult, nil

cni/network/network_linux_test.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package network
55

66
import (
77
"fmt"
8-
"log"
98
"net"
109
"regexp"
1110
"testing"
@@ -511,26 +510,26 @@ func TestPluginLinuxAdd(t *testing.T) {
511510

512511
// compare contents
513512
for _, wantedEndpointEntry := range tt.want {
514-
epId := "none"
513+
epID := "none"
515514
for _, endpointInfo := range allEndpoints {
516-
log.Printf("%v", endpointInfo.NetworkID)
517-
if tt.match(wantedEndpointEntry.epInfo, endpointInfo) {
518-
// save the endpoint id before removing it
519-
epId = endpointInfo.EndpointID
520-
require.Regexp(t, regexp.MustCompile(wantedEndpointEntry.epIDRegex), epId)
515+
if !tt.match(wantedEndpointEntry.epInfo, endpointInfo) {
516+
continue
517+
}
518+
// save the endpoint id before removing it
519+
epID = endpointInfo.EndpointID
520+
require.Regexp(t, regexp.MustCompile(wantedEndpointEntry.epIDRegex), epID)
521521

522-
// omit endpoint id and ifname fields as they are nondeterministic
523-
endpointInfo.EndpointID = ""
524-
endpointInfo.IfName = ""
522+
// omit endpoint id and ifname fields as they are nondeterministic
523+
endpointInfo.EndpointID = ""
524+
endpointInfo.IfName = ""
525525

526-
require.Equal(t, wantedEndpointEntry.epInfo, endpointInfo)
527-
break
528-
}
526+
require.Equal(t, wantedEndpointEntry.epInfo, endpointInfo)
529527
}
530-
if epId == "none" {
528+
if epID == "none" {
531529
t.Fail()
532530
}
533-
tt.plugin.nm.DeleteEndpoint("", epId, nil)
531+
err = tt.plugin.nm.DeleteEndpoint("", epID, nil)
532+
require.NoError(t, err)
534533
}
535534

536535
// confirm separate entities

cni/network/network_windows_test.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ func TestPluginWindowsAdd(t *testing.T) {
955955
epInfo: &network.EndpointInfo{
956956
ContainerID: "test-container",
957957
Data: map[string]interface{}{
958-
"cnetAddressSpace": ([]string)(nil),
958+
"cnetAddressSpace": []string(nil),
959959
},
960960
Routes: []network.RouteInfo{},
961961
EnableSnatOnHost: true,
@@ -1010,7 +1010,7 @@ func TestPluginWindowsAdd(t *testing.T) {
10101010
epInfo: &network.EndpointInfo{
10111011
ContainerID: "test-container",
10121012
Data: map[string]interface{}{
1013-
"cnetAddressSpace": ([]string)(nil),
1013+
"cnetAddressSpace": []string(nil),
10141014
},
10151015
Routes: []network.RouteInfo{},
10161016
EnableSnatOnHost: true,
@@ -1189,25 +1189,26 @@ func TestPluginWindowsAdd(t *testing.T) {
11891189
allEndpoints, _ := tt.plugin.nm.GetAllEndpoints("")
11901190
require.Len(t, allEndpoints, len(tt.want))
11911191
for _, wantedEndpointEntry := range tt.want {
1192-
epId := "none"
1192+
epID := "none"
11931193
for _, endpointInfo := range allEndpoints {
1194-
if tt.match(wantedEndpointEntry.epInfo, endpointInfo) {
1195-
// save the endpoint id before removing it
1196-
epId = endpointInfo.EndpointID
1197-
require.Regexp(t, regexp.MustCompile(wantedEndpointEntry.epIDRegex), epId)
1194+
if !tt.match(wantedEndpointEntry.epInfo, endpointInfo) {
1195+
continue
1196+
}
1197+
// save the endpoint id before removing it
1198+
epID = endpointInfo.EndpointID
1199+
require.Regexp(t, regexp.MustCompile(wantedEndpointEntry.epIDRegex), epID)
11981200

1199-
// omit endpoint id and ifname fields as they are nondeterministic
1200-
endpointInfo.EndpointID = ""
1201-
endpointInfo.IfName = ""
1201+
// omit endpoint id and ifname fields as they are nondeterministic
1202+
endpointInfo.EndpointID = ""
1203+
endpointInfo.IfName = ""
12021204

1203-
require.Equal(t, wantedEndpointEntry.epInfo, endpointInfo)
1204-
break
1205-
}
1205+
require.Equal(t, wantedEndpointEntry.epInfo, endpointInfo)
12061206
}
1207-
if epId == "none" {
1207+
if epID == "none" {
12081208
t.Fail()
12091209
}
1210-
tt.plugin.nm.DeleteEndpoint("", epId, nil)
1210+
err = tt.plugin.nm.DeleteEndpoint("", epID, nil)
1211+
require.NoError(t, err)
12111212
}
12121213

12131214
// ensure deleted

0 commit comments

Comments
 (0)