Repository navigation
test(baseline): cover carriage return and backslash in the canonical corrections form - #112
Merged
Merged
Conversation
…corrections form The canonical form of a correction record is JSON.stringify(record, null, 2) plus a newline (core ADR-0081). JSON.stringify writes a carriage return as \r and a backslash as \\. The B2 table had no case for either escape. Add 5 cases: \r and \\ pass; \u000d, \u000D and \u005c fail with "not in canonical form". Fixes #110
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Author
|
Cross-review:
|
bketelsen
approved these changes
Nov 14, 2026
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.
Why
The B2 baseline test compares each record under
.memory/corrections/with the canonical form of core ADR-0081:JSON.stringify(record, null, 2) + "\n". #108 made the Go serializer (jsonStringify) write the same bytes asJSON.stringify, but the table inTestCorrectionsProblemshad no explicit case for 2 escapes: a carriage return (\r) and a backslash (\\).What
Test-only change in
internal/baseline/repository_baseline_test.go. 5 new rows inTestCorrectionsProblems, beside the newline pair:e \re \u000de \u000De \\e \u005cNo code, docs or behavior change. The serializer from #108 already writes these escapes; these rows guard them.
Evidence
go test ./internal/baseline/ -run TestCorrectionsProblems -v: the 5 new rows pass.\\and\rbranches ofjsonStringifywere removed and the same test ran. 3 rows fail on assertions:a_carriage_return_as_\r_passes: "not in canonical form", want nonea_carriage_return_as_\u000d_fails: no problem, want "not in canonical form"a_backslash_as_\\_passes: "not in canonical form", want nonemake cibefore the push:verify,vuln,test-race,test-packages-dockerandbuild-crosspass.test-integrationcould not run here: the host has rootless Podman in place of Docker, and apt's_aptuser cannot read the bind-mounted test repository (Permission denied). This PR does not touchtest/; CI runs the integration suite with Docker.Fixes #110