Skip to content

Commit

Permalink
Tests: Wait for async deletion APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
JarrettSpiker committed Jul 5, 2022
1 parent 2a4cc50 commit 176ab6e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
15 changes: 12 additions & 3 deletions admin_workspace_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,19 @@ func TestAdminWorkspaces_Delete(t *testing.T) {
err = client.Admin.Workspaces.Delete(ctx, adminWorkspace.ID)
assert.NoError(t, err)

// Admin Workspace client deletion can happen asynchronously
// Retry the read a few times until we get an error
workspaceReadError, _ := retry(func() (interface{}, error) {
_, err = client.Admin.Workspaces.Read(ctx, workspace.ID)
if err != nil {
return err, nil
}
return nil, err
})

// Cannot find deleted workspace
_, err = client.Admin.Workspaces.Read(ctx, workspace.ID)
assert.Error(t, err)
assert.EqualError(t, err, ErrResourceNotFound.Error())
assert.Error(t, workspaceReadError.(error))
assert.EqualError(t, workspaceReadError.(error), ErrResourceNotFound.Error())
})
}

Expand Down
15 changes: 12 additions & 3 deletions oauth_client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,18 @@ func TestOAuthClientsDelete(t *testing.T) {
err := client.OAuthClients.Delete(ctx, ocTest.ID)
require.NoError(t, err)

// Try loading the OAuth client - it should fail.
_, err = client.OAuthClients.Read(ctx, ocTest.ID)
assert.Equal(t, err, ErrResourceNotFound)
// oauth client deletion can happen asynchronously. Retry the read a few times
// until we get an error
oauthReadError, _ := retry(func() (interface{}, error) {
// Try loading the OAuth client - it should fail.
_, err = client.OAuthClients.Read(ctx, ocTest.ID)
if err != nil {
return err, nil
}
return nil, err
})
assert.Equal(t, oauthReadError, ErrResourceNotFound)

})

t.Run("when the OAuth client does not exist", func(t *testing.T) {
Expand Down

0 comments on commit 176ab6e

Please sign in to comment.