Skip to content

Commit cfd7d8b

Browse files
committed
address feedback
1 parent 34ee01b commit cfd7d8b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

npm/pkg/dataplane/ipsets/ipsetmanager_windows_test.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -376,21 +376,23 @@ func TestFailureOnDeletion(t *testing.T) {
376376
verifyDeletedHNSCache(t, toDeleteSetNames, hns)
377377
}
378378

379+
// sorts the Values field of the hcn set policy setting and returns a copy with sorted values
380+
func getSortedHnsPolicySetting(setting *hcn.SetPolicySetting) hcn.SetPolicySetting {
381+
members := strings.Split(setting.Values, ",")
382+
sort.Strings(members)
383+
copyOfSetting := *setting
384+
copyOfSetting.Values = strings.Join(members, ",")
385+
return copyOfSetting
386+
}
387+
379388
func verifyHNSCache(t *testing.T, expected map[string]hcn.SetPolicySetting, hns *hnswrapper.Hnsv2wrapperFake) {
380389
for setName, setObj := range expected {
381390
cacheObj := hns.Cache.SetPolicy(setObj.Id)
382391
require.NotNil(t, cacheObj)
383392

384393
// make values always sorted for testing consistency
385-
members := strings.Split(cacheObj.Values, ",")
386-
sort.Strings(members)
387-
copyOfCachedObj := *cacheObj
388-
copyOfCachedObj.Values = strings.Join(members, ",")
389-
390-
expectedMembers := strings.Split(setObj.Values, ",")
391-
sort.Strings(expectedMembers)
392-
copyOfExpectedObj := setObj
393-
copyOfExpectedObj.Values = strings.Join(expectedMembers, ",")
394+
copyOfCachedObj := getSortedHnsPolicySetting(cacheObj)
395+
copyOfExpectedObj := getSortedHnsPolicySetting(&setObj)
394396

395397
require.Equal(t, copyOfExpectedObj, copyOfCachedObj, setName+" mismatch in cache")
396398
}

0 commit comments

Comments
 (0)