Skip to content

Commit

Permalink
test: sort npm set policy values before validation (#3358)
Browse files Browse the repository at this point in the history
* sort set policy values before validation

* address linter issues

* sort expected values
  • Loading branch information
QxBytes authored Jan 22, 2025
1 parent 3ea76af commit b43c68b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions npm/pkg/dataplane/ipsets/ipsetmanager_windows_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package ipsets

import (
"fmt"
"sort"
"strings"
"testing"

"github.com/Azure/azure-container-networking/common"
Expand Down Expand Up @@ -379,7 +380,19 @@ func verifyHNSCache(t *testing.T, expected map[string]hcn.SetPolicySetting, hns
for setName, setObj := range expected {
cacheObj := hns.Cache.SetPolicy(setObj.Id)
require.NotNil(t, cacheObj)
require.Equal(t, setObj, *cacheObj, fmt.Sprintf("%s mismatch in cache", setName))

// make values always sorted for testing consistency
members := strings.Split(cacheObj.Values, ",")
sort.Strings(members)
copyOfCachedObj := *cacheObj
copyOfCachedObj.Values = strings.Join(members, ",")

expectedMembers := strings.Split(setObj.Values, ",")
sort.Strings(expectedMembers)
copyOfExpectedObj := setObj
copyOfExpectedObj.Values = strings.Join(expectedMembers, ",")

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

Expand Down

0 comments on commit b43c68b

Please sign in to comment.