MCPcopy Index your code
hub / github.com/coder/coder / TestWorker_RespectsShutdown

Function TestWorker_RespectsShutdown

coderd/x/gitsync/worker_test.go:565–598  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

563}
564
565func 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
600func TestWorker_MarkStale_UpsertAndPublish(t *testing.T) {
601 t.Parallel()

Callers

nothing calls this directly

Calls 10

EXPECTMethod · 0.95
StartMethod · 0.95
DoneMethod · 0.95
ContextFunction · 0.92
NewMockStoreFunction · 0.92
NewWorkerFunction · 0.92
newTestRefresherFunction · 0.85
FatalMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected