Skip to content

Commit 7652353

Browse files
authored
Merge pull request kubernetes#104435 from liggitt/convertible-test
Fix slice type comparison bug
2 parents c8a91dc + ccbdf04 commit 7652353

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

plugin/pkg/admission/serviceaccount/admission_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,11 @@ func TestAddImagePullSecrets(t *testing.T) {
747747
{Name: "bar"},
748748
},
749749
}
750+
originalSA := sa.DeepCopy()
751+
expected := []api.LocalObjectReference{
752+
{Name: "foo"},
753+
{Name: "bar"},
754+
}
750755
// Add the default service account for the ns with a secret reference into the cache
751756
informerFactory.Core().V1().ServiceAccounts().Informer().GetStore().Add(sa)
752757

@@ -757,10 +762,10 @@ func TestAddImagePullSecrets(t *testing.T) {
757762
t.Errorf("Unexpected error: %v", err)
758763
}
759764

760-
assert.EqualValues(t, sa.ImagePullSecrets, pod.Spec.ImagePullSecrets, "expected %v, got %v", sa.ImagePullSecrets, pod.Spec.ImagePullSecrets)
765+
assert.EqualValues(t, expected, pod.Spec.ImagePullSecrets, "expected %v, got %v", expected, pod.Spec.ImagePullSecrets)
761766

762767
pod.Spec.ImagePullSecrets[1] = api.LocalObjectReference{Name: "baz"}
763-
if reflect.DeepEqual(sa.ImagePullSecrets, pod.Spec.ImagePullSecrets) {
768+
if !reflect.DeepEqual(originalSA, sa) {
764769
t.Errorf("accidentally mutated the ServiceAccount.ImagePullSecrets: %v", sa.ImagePullSecrets)
765770
}
766771
}

0 commit comments

Comments
 (0)