8000 test(habits): keep the intended created dates in the tied-rank reorder tests by ahmet-cetinkaya · Pull Request #352 · ahmet-cetinkaya/whph · GitHub
[go: up one dir, main page]

Skip to content

test(habits): keep the intended created dates in the tied-rank reorder tests - #352

Merged
ahmet-cetinkaya merged 1 commit into
mainfrom
fix/habit-reorder-tied-rank-flake
Dec 4, 2026
Merged

ahmet-cetinkaya merged 1 commit into
mainfrom
fix/habit-reorder-tied-rank-flake

Conversation

@ahmet-cetinkaya
Copy link
Copy Markdown
Owner

Summary

Fix a flaky test: the tied-rank habit reorder tests failed at random in CI (for example [d, a, b, c] instead of [a, b, c, d]).

Cause

DriftBaseRepository.add stamps created_date with the current time, kept at whole-second precision. The tests set their own creation dates to make the created_date tie-breaker deterministic, but add replaced them. Habits added across a second boundary got different dates, so the sort reordered the tied ranks.

Changes

  • habit_reorder_roundtrip_test.dart: a helper writes the intended creation date back after add. seed() and both tied-rank tests use it. No production code changed.

Testing

  • The file passes (8 of 8).
  • Mutation check: replacing the write-back with a 1.1 s delay before the last insert makes two tests fail with [d, a, b, c], the CI symptom.

…r tests

The repository stamps created_date with the current time on add, at
whole-second precision. Habits added across a second boundary got
different dates, so the tie-breaker reordered them and the tied-rank
tests failed at random (for example d, a, b, c instead of a, b, c, d).
The tests now write the intended created date back after the add.
@ahmet-cetinkaya
ahmet-cetinkaya merged commit 7d06ce0 into main Dec 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0