(t *testing.T)
| 563 | } |
| 564 | |
| 565 | func TestWorker_RespectsShutdown(t *testing.T) { |
| 566 | t.Parallel() |
| 567 | ctx := testutil.Context(t, testutil.WaitShort) |
| 568 | |
| 569 | ctrl := gomock.NewController(t) |
| 570 | store := dbmock.NewMockStore(ctrl) |
| 571 | |
| 572 | store.EXPECT().AcquireStaleChatDiffStatuses(gomock.Any(), gomock.Any()). |
| 573 | Return(nil, nil).AnyTimes() |
| 574 | |
| 575 | mClock := quartz.NewMock(t) |
| 576 | logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}) |
| 577 | refresher := newTestRefresher(t, mClock) |
| 578 | worker := gitsync.NewWorker(store, refresher, nil, mClock, logger) |
| 579 | |
| 580 | trap := mClock.Trap().NewTicker("gitsync", "worker") |
| 581 | defer trap.Close() |
| 582 | |
| 583 | workerCtx, cancel := context.WithCancel(ctx) |
| 584 | go worker.Start(workerCtx) |
| 585 | |
| 586 | // Wait for ticker creation so the worker is running. |
| 587 | trap.MustWait(ctx).MustRelease(ctx) |
| 588 | |
| 589 | // Cancel immediately. |
| 590 | cancel() |
| 591 | |
| 592 | select { |
| 593 | case <-worker.Done(): |
| 594 | // Success — worker shut down. |
| 595 | case <-ctx.Done(): |
| 596 | t.Fatal("timed out waiting for worker to shut down") |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | func TestWorker_MarkStale_UpsertAndPublish(t *testing.T) { |
| 601 | t.Parallel() |
nothing calls this directly
no test coverage detected