MCPcopy Index your code
hub / github.com/coder/coder / TestAPIKey_Deleted

Function TestAPIKey_Deleted

coderd/apikey_test.go:476–491  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

474}
475
476func TestAPIKey_Deleted(t *testing.T) {
477 t.Parallel()
478 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
479 defer cancel()
480 client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
481 user := coderdtest.CreateFirstUser(t, client)
482 _, anotherUser := coderdtest.CreateAnotherUser(t, client, user.OrganizationID)
483 require.NoError(t, client.DeleteUser(context.Background(), anotherUser.ID))
484
485 // Attempt to create an API key for the deleted user. This should fail.
486 _, err := client.CreateAPIKey(ctx, anotherUser.Username)
487 require.Error(t, err)
488 var apiErr *codersdk.Error
489 require.ErrorAs(t, err, &apiErr)
490 require.Equal(t, http.StatusNotFound, apiErr.StatusCode())
491}
492
493func TestAPIKey_SetDefault(t *testing.T) {
494 t.Parallel()

Callers

nothing calls this directly

Calls 8

StatusCodeMethod · 0.95
NewFunction · 0.92
CreateFirstUserFunction · 0.92
CreateAnotherUserFunction · 0.92
DeleteUserMethod · 0.80
CreateAPIKeyMethod · 0.80
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected