Add snap.MatchJSON with dotted-path value masking - #447
Merged
skyrpex merged 2 commits intoAug 11, 2026
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
skyrpex
force-pushed
the
claude/go-testing-tools-11f5d0
branch
from
August 11, 2026 12:43
cd92645 to
f3cd58b
Compare
skyrpex
force-pushed
the
claude/snap-matchjson-stdlib
branch
from
August 11, 2026 12:43
52f7f7f to
862b2c8
Compare
skyrpex
marked this pull request as ready for review
August 11, 2026 12:45
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.
Motivation
Plain-text snapshots need regex sanitizers for volatile values; JSON output deserves structured masking instead — per-path placeholders that also assert the masked field exists.
Solution
snap.MatchJSON(t, raw, "data.currentVersion", ...)— stdlib only, no new dependencies:<any>, re-encodes canonically (two-space indent, sorted keys viaencoding/json, HTML escaping off so the placeholder stays readable), and snapshots through the existingsnap.Matchmachinery (same create/update/CI/cleanup semantics).internal/output:TestEnvelopeSink_UpdateCheckedEnvelopeJSONpins the full--jsonenvelope shape with version fields masked.Second commit fixes a subtle test-harness bug found while writing tests:
MatchJSON's fatal paths lackedreturnaftert.Fatalf, which is invisible under a real*testing.T(Fatalf stops the goroutine) but wrote bogus snapshots under the test suite's fakeTB. Regression test included.Stacked on #443 (in-house
must/snaphelpers) — merge that first; this diff is only the MatchJSON commits.Docs
Docs impact
Nothing to document externally — test-internal tooling. CLAUDE.md's Testing section is updated in this PR with MatchJSON usage.
Review
Human review advisable: same test-tooling direction decision as #443; small diff but it fixes the public helper surface other packages will adopt.
Co-Authored-By: Claude noreply@anthropic.com