(t *testing.T)
| 269 | } |
| 270 | |
| 271 | func 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 | |
| 310 | func TestWorker_NoPR_BoundaryExactWindow_Skips(t *testing.T) { |
| 311 | t.Parallel() |
nothing calls this directly
no test coverage detected