@@ -585,17 +585,13 @@ func TestPostWorkspacesByOrganization(t *testing.T) {
585
585
workspace := coderdtest .CreateWorkspace (t , client , template .ID )
586
586
coderdtest .AwaitWorkspaceBuildJobCompleted (t , client , workspace .LatestBuild .ID )
587
587
588
- var notif * notificationstest.FakeNotification
589
- for _ , n := range enqueuer .Sent () {
590
- if n .TemplateID == notifications .TemplateWorkspaceCreated {
591
- notif = n
592
- break
593
- }
594
- }
595
-
596
- assert .NotNil (t , notif )
597
- assert .Equal (t , user .UserID , notif .UserID )
598
- assert .Equal (t , notifications .TemplateWorkspaceCreated , notif .TemplateID )
588
+ sent := enqueuer .SentWithTemplateID (notifications .TemplateWorkspaceCreated )
589
+ require .Len (t , sent , 1 )
590
+ require .Equal (t , user .UserID , sent [0 ].UserID )
591
+ require .Contains (t , sent [0 ].Targets , template .ID )
592
+ require .Contains (t , sent [0 ].Targets , workspace .ID )
593
+ require .Contains (t , sent [0 ].Targets , workspace .OrganizationID )
594
+ require .Contains (t , sent [0 ].Targets , workspace .OwnerID )
599
595
})
600
596
601
597
t .Run ("CreateWithAuditLogs" , func (t * testing.T ) {
@@ -3623,15 +3619,14 @@ func TestWorkspaceNotifications(t *testing.T) {
3623
3619
3624
3620
// Then
3625
3621
require .NoError (t , err , "mark workspace as dormant" )
3626
- sent := notifyEnq .Sent ()
3627
- require .Len (t , sent , 2 )
3628
- // notifyEnq.Sent[0] is an event for created user account
3629
- require .Equal (t , sent [1 ].TemplateID , notifications .TemplateWorkspaceDormant )
3630
- require .Equal (t , sent [1 ].UserID , workspace .OwnerID )
3631
- require .Contains (t , sent [1 ].Targets , template .ID )
3632
- require .Contains (t , sent [1 ].Targets , workspace .ID )
3633
- require .Contains (t , sent [1 ].Targets , workspace .OrganizationID )
3634
- require .Contains (t , sent [1 ].Targets , workspace .OwnerID )
3622
+ sent := notifyEnq .SentWithTemplateID (notifications .TemplateWorkspaceDormant )
3623
+ require .Len (t , sent , 1 )
3624
+ require .Equal (t , sent [0 ].TemplateID , notifications .TemplateWorkspaceDormant )
3625
+ require .Equal (t , sent [0 ].UserID , workspace .OwnerID )
3626
+ require .Contains (t , sent [0 ].Targets , template .ID )
3627
+ require .Contains (t , sent [0 ].Targets , workspace .ID )
3628
+ require .Contains (t , sent [0 ].Targets , workspace .OrganizationID )
3629
+ require .Contains (t , sent [0 ].Targets , workspace .OwnerID )
3635
3630
})
3636
3631
3637
3632
t .Run ("InitiatorIsOwner" , func (t * testing.T ) {
@@ -3662,7 +3657,7 @@ func TestWorkspaceNotifications(t *testing.T) {
3662
3657
3663
3658
// Then
3664
3659
require .NoError (t , err , "mark workspace as dormant" )
3665
- require .Len (t , notifyEnq .Sent ( ), 0 )
3660
+ require .Len (t , notifyEnq .SentWithTemplateID ( notifications . TemplateWorkspaceDormant ), 0 )
3666
3661
})
3667
3662
3668
3663
t .Run ("ActivateDormantWorkspace" , func (t * testing.T ) {
0 commit comments