@@ -322,11 +322,6 @@ func TestPrebuildReconciliation(t *testing.T) {
322322t ,& slogtest.Options {IgnoreErrors :true },
323323).Leveled (slog .LevelDebug )
324324db ,pubSub := dbtestutil .NewDB (t )
325- if useBrokenPubsub {
326- pubSub = & brokenPublisher {Pubsub :pubSub }
327- }
328-
329- controller := prebuilds .NewStoreReconciler (db ,pubSub ,cfg ,logger ,quartz .NewMock (t ),prometheus .NewRegistry ())
330325
331326ownerID := uuid .New ()
332327dbgen .User (t ,db , database.User {
@@ -369,6 +364,11 @@ func TestPrebuildReconciliation(t *testing.T) {
369364setupTestDBTemplateVersion (ctx ,t ,clock ,db ,pubSub ,org .ID ,ownerID ,template .ID )
370365}
371366
367+ if useBrokenPubsub {
368+ pubSub = & brokenPublisher {Pubsub :pubSub }
369+ }
370+ controller := prebuilds .NewStoreReconciler (db ,pubSub ,cfg ,logger ,quartz .NewMock (t ),prometheus .NewRegistry ())
371+
372372// Run the reconciliation multiple times to ensure idempotency
373373// 8 was arbitrary, but large enough to reasonably trust the result
374374for i := 1 ;i <= 8 ;i ++ {
@@ -417,10 +417,13 @@ type brokenPublisher struct {
417417pubsub.Pubsub
418418}
419419
420+ // Publish deliberately fails.
421+ // I'm explicitly _not_ checking for EventJobPosted (coderd/database/provisionerjobs/provisionerjobs.go) since that
422+ // requires too much knowledge of the underlying implementation.
420423func (* brokenPublisher )Publish (event string ,_ []byte )error {
421- //I'm explicitly _not_ checking for EventJobPosted (coderd/database/provisionerjobs/provisionerjobs.go) since that
422- // requires too much knowledge of the underlying implementation.
423- return xerrors .Errorf ("refusing to publish %q" ,event )
424+ //Mimick some work being done.
425+ <- time . After ( testutil . IntervalFast )
426+ return xerrors .Errorf ("failed to publish %q" ,event )
424427}
425428
426429func TestMultiplePresetsPerTemplateVersion (t * testing.T ) {