Skip to content

Commit b174ea4

Browse files
committed
fix test
1 parent 401ec20 commit b174ea4

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

coderd/notifications/notifications_test.go

+5-10
Original file line numberDiff line numberDiff line change
@@ -2125,25 +2125,20 @@ func TestNotificationEnqueuePubsubNotify(t *testing.T) {
21252125

21262126
user := createSampleUser(t, store)
21272127

2128-
// When: a notification is enqueued
2129-
2130-
// Then: we attempt to dispatch the notification immediately.
2128+
// Given: the manager is running and the fetch interval is set to 1 minute.
21312129
mgr.Run(ctx)
2132-
wt := fetchTrap.MustWait(ctx)
2133-
// TODO: this happens *before* manager starts listening. Need to wait.
2130+
fetchTrap.MustWait(ctx).Release() // Wait for one tick of the notifier to elapse.
2131+
2132+
// When: a notification is enqueued
21342133
_, err = enq.Enqueue(ctx, user.ID, notifications.TemplateWorkspaceDeleted, map[string]string{}, "test")
21352134
require.NoError(t, err)
2136-
wt.Release()
2137-
d, w := mClock.AdvanceNext()
2138-
t.Logf("advanced %s", d)
21392135

2136+
// Then: we attempt to dispatch the notification immediately.
21402137
call := testutil.TryReceive(ctx, t, handler.calls)
21412138
testutil.RequireSend(ctx, t, call.result, dispatchResult{
21422139
retryable: false,
21432140
err: nil,
21442141
})
2145-
2146-
<-w.Done() // TODO: this hangs and fails.
21472142
}
21482143

21492144
type fakeHandler struct {

coderd/notifications/notifier.go

-5
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@ func (n *notifier) run(success chan<- dispatchResult, failure chan<- dispatchRes
108108
n.log.Info(context.Background(), "gracefully stopped")
109109
}()
110110

111-
// TODO: idea from Cian: instead of querying the database on a short interval, we could wait for pubsub notifications.
112-
// if 100 notifications are enqueued, we shouldn't activate this routine for each one; so how to debounce these?
113-
// PLUS we should also have an interval (but a longer one, maybe 1m) to account for retries (those will not get
114-
// triggered by a code path, but rather by a timeout expiring which makes the message retryable)
115-
116111
// loopTick is used to synchronize the goroutine that processes messages with the ticker.
117112
loopTick := make(chan chan struct{})
118113
// loopDone is used to signal when the processing loop has exited due to

0 commit comments

Comments
 (0)