cleanup(controller): use IsSuperset to avoid interim slice

This commit is contained in:
binacs 2023-02-19 21:49:58 +08:00
parent d6fe718e19
commit 84ff621309
2 changed files with 3 additions and 3 deletions

View File

@ -35,7 +35,7 @@ func CheckQueueEq(lhs []string, rhs TimedQueue) bool {
} }
func CheckSetEq(lhs, rhs sets.String) bool { func CheckSetEq(lhs, rhs sets.String) bool {
return lhs.HasAll(rhs.List()...) && rhs.HasAll(lhs.List()...) return lhs.IsSuperset(rhs) && rhs.IsSuperset(lhs)
} }
func TestAddNode(t *testing.T) { func TestAddNode(t *testing.T) {

View File

@ -26,7 +26,7 @@ import (
"testing" "testing"
"time" "time"
"k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
@ -797,7 +797,7 @@ func TestSyncResourceQuota(t *testing.T) {
for _, action := range kubeClient.Actions() { for _, action := range kubeClient.Actions() {
actionSet.Insert(strings.Join([]string{action.GetVerb(), action.GetResource().Resource, action.GetSubresource()}, "-")) actionSet.Insert(strings.Join([]string{action.GetVerb(), action.GetResource().Resource, action.GetSubresource()}, "-"))
} }
if !actionSet.HasAll(testCase.expectedActionSet.List()...) { if !actionSet.IsSuperset(testCase.expectedActionSet) {
t.Errorf("test: %s,\nExpected actions:\n%v\n but got:\n%v\nDifference:\n%v", testName, testCase.expectedActionSet, actionSet, testCase.expectedActionSet.Difference(actionSet)) t.Errorf("test: %s,\nExpected actions:\n%v\n but got:\n%v\nDifference:\n%v", testName, testCase.expectedActionSet, actionSet, testCase.expectedActionSet.Difference(actionSet))
} }