Skip to content

Commit 59e57ac

Browse files
committed
chore(coderd): add more robust testing assertions to TestNotifyDeletedUser
1 parent 9e938e5 commit 59e57ac

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

coderd/users_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,16 @@ func TestNotifyDeletedUser(t *testing.T) {
489489
adminClient := coderdtest.New(t, &coderdtest.Options{
490490
NotificationsEnqueuer: notifyEnq,
491491
})
492-
firstUser := coderdtest.CreateFirstUser(t, adminClient)
492+
firstUserResponse := coderdtest.CreateFirstUser(t, adminClient)
493493

494494
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
495495
defer cancel()
496496

497+
firstUser, err := adminClient.User(ctx, firstUserResponse.UserID.String())
498+
require.NoError(t, err)
499+
497500
user, err := adminClient.CreateUserWithOrgs(ctx, codersdk.CreateUserRequestWithOrgs{
498-
OrganizationIDs: []uuid.UUID{firstUser.OrganizationID},
501+
OrganizationIDs: []uuid.UUID{firstUserResponse.OrganizationID},
499502
Email: "another@user.org",
500503
Username: "someone-else",
501504
Password: "SomeSecurePassword!",
@@ -510,12 +513,11 @@ func TestNotifyDeletedUser(t *testing.T) {
510513
require.Len(t, notifyEnq.Sent, 2)
511514
// notifyEnq.Sent[0] is create account event
512515
require.Equal(t, notifications.TemplateUserAccountDeleted, notifyEnq.Sent[1].TemplateID)
513-
require.Equal(t, firstUser.UserID, notifyEnq.Sent[1].UserID)
516+
require.Equal(t, firstUser.ID, notifyEnq.Sent[1].UserID)
514517
require.Contains(t, notifyEnq.Sent[1].Targets, user.ID)
515518
require.Equal(t, user.Username, notifyEnq.Sent[1].Labels["deleted_account_name"])
516519
require.Equal(t, user.Name, notifyEnq.Sent[1].Labels["deleted_account_user_name"])
517-
// Not sure where to get the following just yet
518-
// require.Equal(t, , notifyEnq.Sent[1].Labels["account_deleter_user_name"])
520+
require.Equal(t, firstUser.Name, notifyEnq.Sent[1].Labels["account_deleter_user_name"])
519521
})
520522

521523
t.Run("UserAdminNotified", func(t *testing.T) {

0 commit comments

Comments
 (0)