MCPcopy Create free account
hub / github.com/coder/coder / TestWorker_NoPR_OldRow_Skips

Function TestWorker_NoPR_OldRow_Skips

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

Source from the content-addressed store, hash-verified

269}
270
271func TestWorker_NoPR_OldRow_Skips(t *testing.T) {
272 t.Parallel()
273 ctx := testutil.Context(t, testutil.WaitShort)
274
275 chatID := uuid.New()
276 ownerID := uuid.New()
277
278 // When the Refresher returns (nil, nil) but the row's
279 // updated_at is outside the NoPRRetryWindow, the worker should
280 // skip the row entirely (no backoff call) and let the 5-minute
281 // acquisition lock serve as the natural retry interval.
282 tickDone := make(chan struct{})
283
284 ctrl := gomock.NewController(t)
285 store := dbmock.NewMockStore(ctrl)
286
287 mClock := quartz.NewMock(t)
288
289 row := makeAcquiredRowWithBranch(chatID, ownerID, "feature")
290 row.UpdatedAt = mClock.Now().Add(-5 * time.Minute) // old row
291
292 store.EXPECT().AcquireStaleChatDiffStatuses(gomock.Any(), gomock.Any()).
293 Return([]database.AcquireStaleChatDiffStatusesRow{row}, nil)
294 // BackoffChatDiffStatus should NOT be called.
295
296 logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
297
298 refresher := newTestRefresher(t, mClock, withResolveBranchPR(
299 func(context.Context, string, gitprovider.BranchRef) (*gitprovider.PRRef, error) {
300 close(tickDone)
301 return nil, nil
302 },
303 ))
304
305 worker := gitsync.NewWorker(store, refresher, nil, mClock, logger)
306
307 tickOnce(ctx, t, mClock, worker, tickDone)
308}
309
310func TestWorker_NoPR_BoundaryExactWindow_Skips(t *testing.T) {
311 t.Parallel()

Callers

nothing calls this directly

Calls 11

EXPECTMethod · 0.95
ContextFunction · 0.92
NewMockStoreFunction · 0.92
NewWorkerFunction · 0.92
newTestRefresherFunction · 0.85
withResolveBranchPRFunction · 0.85
tickOnceFunction · 0.85
NewMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected