Skip to content

Commit

Permalink
add test for keyring failure
Browse files Browse the repository at this point in the history
  • Loading branch information
DiogoFerrao committed May 31, 2024
1 parent ecc5d7b commit e6412a1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/pkg/auth/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ func TestDeleteAuthFieldKeyring(t *testing.T) {
func TestDeleteProfileFromKeyring(t *testing.T) {
tests := []struct {
description string
keyringFails bool
keys []authFieldKey
activeProfile string
isValid bool
Expand Down Expand Up @@ -586,11 +587,20 @@ func TestDeleteProfileFromKeyring(t *testing.T) {
activeProfile: "INVALID",
isValid: false,
},
{
description: "keyring fails",
keyringFails: true,
isValid: false,
},
}

for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
keyring.MockInit()
if !tt.keyringFails {
keyring.MockInit()
} else {
keyring.MockInitWithError(fmt.Errorf("keyring unavailable for testing"))
}

// Append random string to auth field key and value to avoid conflicts
testValue1 := fmt.Sprintf("value-1-keyring-%s", time.Now().Format(time.RFC3339))
Expand Down

0 comments on commit e6412a1

Please sign in to comment.