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

Function TestDormantUser

coderd/users_test.go:2739–2775  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2737}
2738
2739func TestDormantUser(t *testing.T) {
2740 t.Parallel()
2741
2742 client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
2743 user := coderdtest.CreateFirstUser(t, client)
2744
2745 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
2746 defer cancel()
2747
2748 // Create a new user
2749 newUser, err := client.CreateUserWithOrgs(ctx, codersdk.CreateUserRequestWithOrgs{
2750 Email: "test@coder.com",
2751 Username: "someone",
2752 Password: "MySecurePassword!",
2753 OrganizationIDs: []uuid.UUID{user.OrganizationID},
2754 })
2755 require.NoError(t, err)
2756
2757 // User should be dormant as they haven't logged in yet
2758 users, err := client.Users(ctx, codersdk.UsersRequest{Search: newUser.Username})
2759 require.NoError(t, err)
2760 require.Len(t, users.Users, 1)
2761 require.Equal(t, codersdk.UserStatusDormant, users.Users[0].Status)
2762
2763 // User logs in now
2764 _, err = client.LoginWithPassword(ctx, codersdk.LoginWithPasswordRequest{
2765 Email: newUser.Email,
2766 Password: "MySecurePassword!",
2767 })
2768 require.NoError(t, err)
2769
2770 // User status should be active now
2771 users, err = client.Users(ctx, codersdk.UsersRequest{Search: newUser.Username})
2772 require.NoError(t, err)
2773 require.Len(t, users.Users, 1)
2774 require.Equal(t, codersdk.UserStatusActive, users.Users[0].Status)
2775}
2776
2777// TestSuspendedPagination is when the after_id is a suspended record.
2778// The database query should still return the correct page, as the after_id

Callers

nothing calls this directly

Calls 7

NewFunction · 0.92
CreateFirstUserFunction · 0.92
CreateUserWithOrgsMethod · 0.80
LoginWithPasswordMethod · 0.80
UsersMethod · 0.65
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected