From b26b3f8e15b85812ab64b67e06171888f49489e0 Mon Sep 17 00:00:00 2001 From: njhale Date: Thu, 10 Jan 2019 11:43:53 -0500 Subject: [PATCH] test(unit): fix TestAPIMultiOwnerSet_PopAPIKey tests --- .../registry/resolver/operators_test.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pkg/controller/registry/resolver/operators_test.go b/pkg/controller/registry/resolver/operators_test.go index 4b7437c81e9..6aa005d29fb 100644 --- a/pkg/controller/registry/resolver/operators_test.go +++ b/pkg/controller/registry/resolver/operators_test.go @@ -47,12 +47,10 @@ func TestAPIMultiOwnerSet_PopAPIKey(t *testing.T) { tests := []struct { name string s APIMultiOwnerSet - want *opregistry.APIKey }{ { name: "Empty", s: EmptyAPIMultiOwnerSet(), - want: nil, }, { name: "OneApi/OneOwner", @@ -61,7 +59,6 @@ func TestAPIMultiOwnerSet_PopAPIKey(t *testing.T) { "owner1": &Operator{name: "op1"}, }, }, - want: &opregistry.APIKey{"g", "v", "k", "p"}, }, { name: "OneApi/MultiOwner", @@ -71,7 +68,6 @@ func TestAPIMultiOwnerSet_PopAPIKey(t *testing.T) { "owner2": &Operator{name: "op2"}, }, }, - want: &opregistry.APIKey{"g", "v", "k", "p"}, }, { name: "MultipleApi/MultiOwner", @@ -85,24 +81,20 @@ func TestAPIMultiOwnerSet_PopAPIKey(t *testing.T) { "owner2": &Operator{name: "op2"}, }, }, - want: &opregistry.APIKey{"g", "v", "k", "p"}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { startLen := len(tt.s) - require.Equal(t, tt.s.PopAPIKey(), tt.want) - // Verify entry removed once popped - if tt.want != nil { - _, ok := tt.s[*tt.want] - require.False(t, ok) - } + popped := tt.s.PopAPIKey() - // Verify len has decreased if startLen == 0 { + require.Nil(t, popped, "popped key from empty MultiOwnerSet should be nil") require.Equal(t, 0, len(tt.s)) } else { + _, found := tt.s[*popped] + require.False(t, found, "popped key should not still exist in set") require.Equal(t, startLen-1, len(tt.s)) } })