@@ -2152,16 +2152,27 @@ func TestNotificationEnqueuePubsubNotify(t *testing.T) {
2152
2152
mgr .Run (ctx )
2153
2153
fetchTrap .MustWait (ctx ).Release ()
2154
2154
2155
- // When: a notification is enqueued
2156
- _ , err = enq .Enqueue (ctx , user .ID , notifications .TemplateWorkspaceDeleted , map [string ]string {}, "test" )
2157
- require .NoError (t , err )
2155
+ // When: a number of notifications are enqueued
2156
+ const numEnqueued = 10
2157
+ for i := range numEnqueued {
2158
+ _ , err = enq .Enqueue (ctx , user .ID , notifications .TemplateWorkspaceDeleted , map [string ]string {"i" : fmt .Sprintf ("%d" , i )}, fmt .Sprintf ("test %d" , i ))
2159
+ require .NoError (t , err )
2160
+ }
2158
2161
2159
2162
// Then: we attempt to dispatch the notification immediately.
2160
- call := testutil .TryReceive (ctx , t , handler .calls )
2161
- testutil .RequireSend (ctx , t , call .result , dispatchResult {
2162
- retryable : false ,
2163
- err : nil ,
2164
- })
2163
+ recvDone := make (chan struct {})
2164
+ go func () {
2165
+ defer close (recvDone )
2166
+ for range numEnqueued {
2167
+ call := testutil .TryReceive (ctx , t , handler .calls )
2168
+ <- time .After (testutil .IntervalFast ) // Simulate some processing time.
2169
+ testutil .RequireSend (ctx , t , call .result , dispatchResult {
2170
+ retryable : false ,
2171
+ err : nil ,
2172
+ })
2173
+ }
2174
+ }()
2175
+ _ = testutil .TryReceive (ctx , t , recvDone )
2165
2176
}
2166
2177
2167
2178
type fakeHandler struct {
0 commit comments