mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 13:31:52 +00:00
check key is set before deleting from map
This commit is contained in:
parent
4d8c3530f5
commit
852c03a49b
@ -313,7 +313,9 @@ func TestServiceAccountTokenCreate(t *testing.T) {
|
||||
|
||||
info := doTokenReview(t, cs, treq, false)
|
||||
// we are not testing the credential-id feature, so delete this value from the returned extra info map
|
||||
delete(info.Extra, apiserverserviceaccount.CredentialIDKey)
|
||||
if _, ok := info.Extra[apiserverserviceaccount.CredentialIDKey]; ok {
|
||||
delete(info.Extra, apiserverserviceaccount.CredentialIDKey)
|
||||
}
|
||||
if len(info.Extra) != 2 {
|
||||
t.Fatalf("expected Extra have length of 2 but was length %d: %#v", len(info.Extra), info.Extra)
|
||||
}
|
||||
@ -409,7 +411,9 @@ func TestServiceAccountTokenCreate(t *testing.T) {
|
||||
|
||||
info := doTokenReview(t, cs, treq, false)
|
||||
// we are not testing the credential-id feature, so delete this value from the returned extra info map
|
||||
delete(info.Extra, apiserverserviceaccount.CredentialIDKey)
|
||||
if _, ok := info.Extra[apiserverserviceaccount.CredentialIDKey]; ok {
|
||||
delete(info.Extra, apiserverserviceaccount.CredentialIDKey)
|
||||
}
|
||||
if len(info.Extra) != len(expectedExtraValues) {
|
||||
t.Fatalf("expected Extra have length of %d but was length %d: %#v", len(expectedExtraValues), len(info.Extra), info.Extra)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user