@@ -322,11 +322,6 @@ func TestPrebuildReconciliation(t *testing.T) {
322322 t , & slogtest.Options {IgnoreErrors : true },
323323 ).Leveled (slog .LevelDebug )
324324 db , 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
331326 ownerID := uuid .New ()
332327 dbgen .User (t , db , database.User {
@@ -369,6 +364,11 @@ func TestPrebuildReconciliation(t *testing.T) {
369364 setupTestDBTemplateVersion (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
374374 for i := 1 ; i <= 8 ; i ++ {
@@ -417,10 +417,13 @@ type brokenPublisher struct {
417417 pubsub.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 ) {
0 commit comments