@@ -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+
379388func 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