Skip to content

Commit

Permalink
sorted the result of GetDosProtectedThatReferencedDosPolicy in unit t…
Browse files Browse the repository at this point in the history
…est to make it deterministic (#2289)
  • Loading branch information
soneillf5 authored Dec 17, 2021
1 parent 3e6db80 commit f957d7b
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package appprotectdos

import (
"sort"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -1150,15 +1151,17 @@ func TestGetDosProtectedThatReferencedDosPolicy(t *testing.T) {
policyNamespace: "dev",
policyName: "dosPolicyTwo",
expected: []*v1beta1.DosProtectedResource{
dosProtectedWithPolicyTwo,
anotherDosProtectedWithPolicyTwo,
dosProtectedWithPolicyTwo,
},
msg: "return two referenced objects, from policy reference with mixed namespaces",
},
}
for _, test := range tests {
resources := dosConf.GetDosProtectedThatReferencedDosPolicy(test.policyNamespace + "/" + test.policyName)

sort.SliceStable(resources, func(i, j int) bool {
return resources[i].Name < resources[j].Name
})
if diff := cmp.Diff(test.expected, resources); diff != "" {
t.Errorf("GetDosProtectedThatReferencedDosPolicy() returned unexpected result for the case of: %v (-want +got):\n%s", test.msg, diff)
}
Expand Down

0 comments on commit f957d7b

Please sign in to comment.