@@ -322,11 +322,6 @@ func TestPrebuildReconciliation(t *testing.T) {
322
322
t , & slogtest.Options {IgnoreErrors : true },
323
323
).Leveled (slog .LevelDebug )
324
324
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 ())
330
325
331
326
ownerID := uuid .New ()
332
327
dbgen .User (t , db , database.User {
@@ -369,6 +364,11 @@ func TestPrebuildReconciliation(t *testing.T) {
369
364
setupTestDBTemplateVersion (ctx , t , clock , db , pubSub , org .ID , ownerID , template .ID )
370
365
}
371
366
367
+ if useBrokenPubsub {
368
+ pubSub = & brokenPublisher {Pubsub : pubSub }
369
+ }
370
+ controller := prebuilds .NewStoreReconciler (db , pubSub , cfg , logger , quartz .NewMock (t ), prometheus .NewRegistry ())
371
+
372
372
// Run the reconciliation multiple times to ensure idempotency
373
373
// 8 was arbitrary, but large enough to reasonably trust the result
374
374
for i := 1 ; i <= 8 ; i ++ {
@@ -417,10 +417,13 @@ type brokenPublisher struct {
417
417
pubsub.Pubsub
418
418
}
419
419
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.
420
423
func (* 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 )
424
427
}
425
428
426
429
func TestMultiplePresetsPerTemplateVersion (t * testing.T ) {
0 commit comments