Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: sort npm set policy values before validation #3358

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading