Repository navigation
fix(tests): give mock records unique IDs - #451
Merged
Merged
Conversation
The mock database and blob store named new records
fmt.Sprintf("mock-%d", time.Now().UnixNano()). On macOS the wall clock
advances once per microsecond, so records created back to back got the
same ID and overwrote each other in the mock's maps.
TestRepositoriesHandler_HandleList_Pagination and _FormatFilter failed
20 out of 20 runs on an Apple Silicon Mac ("expected total=3, got 2").
Add mockID, which appends a package-wide counter to the timestamp, and
use it for all eight generated IDs.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two tests in
tests/fail every time on an Apple Silicon Mac:The mock database names new records
fmt.Sprintf("mock-%d", time.Now().UnixNano()). On macOS the wall clock advances once per microsecond, so repositories seeded back to back get the same ID and overwrite each other in the mock's map. On Linux the clock is fine-grained enough that it rarely shows, which is why CI is green.This adds
mockID, which appends a package-wide atomic counter to the timestamp, and uses it for all eight generated IDs intests/rpm_db_wiring_test.go(sevenmock-and oneblob-). The timestamp stays, so the IDs keep their shape and can't collide with hard-coded ones likeblob-1. Test-only change. The two tests above are the regression tests: they fail without this on macOS.Checked on macOS: the two tests pass 50 of 50 runs,
make checkpasses, andgo test -short ./...passes with and without-tags noai,nomcp(race on for the default build).Found while preparing the slim-tag CI follow-up from #448, which comes next as its own PR.
🤖 Generated with Claude Code