Skip to content

Commit

Permalink
the logs indicate that the same key is deleted twice, the 2nd time fa…
Browse files Browse the repository at this point in the history
…ils because it's already deleted
  • Loading branch information
jeroenvervaeke committed Oct 31, 2024
1 parent 638c43f commit 39d801d
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions test/e2e/atlas/atlas_e2e_test_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,24 +278,30 @@ func deleteKeys(t *testing.T, cliPath string, toDelete map[string]struct{}) {
var keys atlasv2.PaginatedApiApiUser
err = json.Unmarshal(resp, &keys)
require.NoError(t, err)

uniqueKeysToDelete := make(map[string]struct{})
for _, key := range keys.GetResults() {
keyID := key.GetId()
desc := key.GetDesc()

errors := []error{}
if _, ok := toDelete[desc]; ok {
t.Logf("Deleting key with ID: %s", keyID)
cmd = exec.Command(cliPath,
orgEntity,
"apiKeys",
"rm",
keyID,
"--force")
cmd.Env = os.Environ()
_, err = e2e.RunAndGetStdOut(cmd)
if err != nil {
errors = append(errors, err)
}
uniqueKeysToDelete[keyID] = struct{}{}
}
}

for keyID := range uniqueKeysToDelete {
errors := []error{}
t.Logf("Deleting key with ID: %s", keyID)
cmd = exec.Command(cliPath,
orgEntity,
"apiKeys",
"rm",
keyID,
"--force")
cmd.Env = os.Environ()
_, err = e2e.RunAndGetStdOut(cmd)
if err != nil {
errors = append(errors, err)
}
if len(errors) > 0 {
t.Errorf("unexpected errors while deleting keys: %v", errors)
Expand Down

0 comments on commit 39d801d

Please sign in to comment.