Skip to content

Commit efe03c1

Browse files
committed
test options and data are created for each endpoint info
1 parent 81c89fc commit efe03c1

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

cni/network/network_linux_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,8 @@ func TestPluginLinuxAdd(t *testing.T) {
508508
require.NoError(t, err)
509509
allEndpoints, _ := tt.plugin.nm.GetAllEndpoints("")
510510
require.Len(t, allEndpoints, len(tt.want))
511+
512+
// compare contents
511513
for _, wantedEndpointEntry := range tt.want {
512514
epId := "none"
513515
for _, endpointInfo := range allEndpoints {
@@ -531,6 +533,23 @@ func TestPluginLinuxAdd(t *testing.T) {
531533
tt.plugin.nm.DeleteEndpoint("", epId, nil)
532534
}
533535

536+
// confirm separate entities
537+
// that is, if one is modified, the other should not be modified
538+
epInfos := []*network.EndpointInfo{}
539+
for _, val := range allEndpoints {
540+
epInfos = append(epInfos, val)
541+
}
542+
if len(epInfos) > 1 {
543+
epInfo1 := epInfos[0]
544+
epInfo2 := epInfos[1]
545+
epInfo1.Data["dummy"] = "dummy value"
546+
epInfo1.Options["dummy"] = "another dummy value"
547+
require.NotEqual(t, epInfo1.Data, epInfo2.Data)
548+
require.NotEqual(t, epInfo1.Options, epInfo2.Options)
549+
}
550+
551+
// ensure deleted
552+
require.Empty(t, allEndpoints)
534553
})
535554
}
536555
}

cni/network/network_windows_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,8 @@ func TestPluginWindowsAdd(t *testing.T) {
12101210
tt.plugin.nm.DeleteEndpoint("", epId, nil)
12111211
}
12121212

1213+
// ensure deleted
1214+
require.Empty(t, allEndpoints)
12131215
})
12141216
}
12151217
}

0 commit comments

Comments
 (0)