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

Function TestWorker_NoPR_BoundaryExactWindow_Skips

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

Source from the content-addressed store, hash-verified

308}
309
310func TestWorker_NoPR_BoundaryExactWindow_Skips(t *testing.T) {
311 t.Parallel()
312 ctx := testutil.Context(t, testutil.WaitShort)
313
314 chatID := uuid.New()
315 ownerID := uuid.New()
316
317 // When updated_at is exactly NoPRRetryWindow ago, the strict
318 // "<" comparison means the row should be skipped (no backoff).
319 // This pins the boundary so an accidental change to "<=" is
320 // caught.
321 tickDone := make(chan struct{})
322
323 ctrl := gomock.NewController(t)
324 store := dbmock.NewMockStore(ctrl)
325
326 mClock := quartz.NewMock(t)
327
328 row := makeAcquiredRowWithBranch(chatID, ownerID, "feature")
329 row.UpdatedAt = mClock.Now().Add(-gitsync.NoPRRetryWindow) // exactly at boundary
330
331 store.EXPECT().AcquireStaleChatDiffStatuses(gomock.Any(), gomock.Any()).
332 Return([]database.AcquireStaleChatDiffStatusesRow{row}, nil)
333 // BackoffChatDiffStatus should NOT be called.
334
335 logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
336
337 refresher := newTestRefresher(t, mClock, withResolveBranchPR(
338 func(context.Context, string, gitprovider.BranchRef) (*gitprovider.PRRef, error) {
339 close(tickDone)
340 return nil, nil
341 },
342 ))
343
344 worker := gitsync.NewWorker(store, refresher, nil, mClock, logger)
345
346 tickOnce(ctx, t, mClock, worker, tickDone)
347}
348
349func TestWorker_NoPR_BackoffError_ContinuesNextRow(t *testing.T) {
350 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