Skip to content

Commit

Permalink
Merge pull request kubernetes#104435 from liggitt/convertible-test
Browse files Browse the repository at this point in the history
Fix slice type comparison bug
  • Loading branch information
k8s-ci-robot committed Aug 20, 2021
2 parents c8a91dc + ccbdf04 commit 7652353
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions plugin/pkg/admission/serviceaccount/admission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,11 @@ func TestAddImagePullSecrets(t *testing.T) {
{Name: "bar"},
},
}
originalSA := sa.DeepCopy()
expected := []api.LocalObjectReference{
{Name: "foo"},
{Name: "bar"},
}
// Add the default service account for the ns with a secret reference into the cache
informerFactory.Core().V1().ServiceAccounts().Informer().GetStore().Add(sa)

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

assert.EqualValues(t, sa.ImagePullSecrets, pod.Spec.ImagePullSecrets, "expected %v, got %v", sa.ImagePullSecrets, pod.Spec.ImagePullSecrets)
assert.EqualValues(t, expected, pod.Spec.ImagePullSecrets, "expected %v, got %v", expected, pod.Spec.ImagePullSecrets)

pod.Spec.ImagePullSecrets[1] = api.LocalObjectReference{Name: "baz"}
if reflect.DeepEqual(sa.ImagePullSecrets, pod.Spec.ImagePullSecrets) {
if !reflect.DeepEqual(originalSA, sa) {
t.Errorf("accidentally mutated the ServiceAccount.ImagePullSecrets: %v", sa.ImagePullSecrets)
}
}
Expand Down

0 comments on commit 7652353

Please sign in to comment.