Repository navigation
test: strengthen display handler test assertions - #2055
Merged
TerryHowe merged 1 commit intoJul 21, 2026
Merged
Conversation
TerryHowe
requested review from
Wwwsylvia,
sabre1041,
sajayantony and
shizhMSFT
as code owners
May 24, 2026 16:48
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2055 +/- ##
=======================================
Coverage 87.25% 87.25%
=======================================
Files 138 138
Lines 5462 5462
=======================================
Hits 4766 4766
Misses 415 415
Partials 281 281 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Follow-up to oras-project#1950 addressing Copilot review feedback: - assert that OnTagged/OnCopied actually store the tag, path, and root - assert that OnCopied with a digest reference does NOT add a tag - assert that OnFilePulled records the file in the pulled list - assert rendered JSON contains the expected reference, digest, mediaType, size, files, and referenceAsTags rather than only validating that the output parses. Signed-off-by: Terry Howe <[email protected]>
TerryHowe
force-pushed
the
test/display-handler-assertions
branch
from
May 24, 2026 16:54
fbb9ac6 to
7111654
Compare
sajayantony
approved these changes
Jul 21, 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.
Summary
Follow-up to #1950 that addresses the Copilot review feedback left on that PR. The previously added tests only asserted that handler methods returned no error; this PR adds assertions on the state mutations and rendered JSON output that those methods are actually supposed to produce.
Note
This branch is stacked on #1950. It currently shows that PR's commits plus this one in the diff. Please merge #1950 first — once that lands, GitHub will recompute this PR's diff to show only the changes here.
Changes
cmd/oras/internal/display/metadata/json/push_test.goTestPushHandler_OnTaggednow asserts the tag is stored inhandler.tagged.Tags().TestPushHandler_OnCopiednow assertshandler.path,handler.root.Digest, and that the non-digest reference was added as a tag.TestPushHandler_OnCopied_WithDigestnow asserts that no tag is added when the reference is a digest — the whole purpose of that code path.TestPushHandler_Rendernow decodes the JSON into a typed struct and assertsreference,mediaType,digest,size, andreferenceAsTagsrather than only checking that the output parses.cmd/oras/internal/display/metadata/json/pull_test.goTestPullHandler_OnFilePullednow asserts the file was recorded inhandler.pulled.Files()with the expected digest and media type.TestPullHandler_Rendernow callsOnFilePulledbefore rendering and decodes the output into a typed struct, assertingreferenceand thefilesarray contents.cmd/oras/internal/display/content/discard_test.gotparameter inTestDiscardHandler_ImplementsInterfacesto_so the branch passesrevive'sunused-parametercheck.Test plan
go test ./cmd/oras/internal/display/metadata/json/... ./cmd/oras/internal/display/content/...passesgolangci-lint run ./cmd/oras/internal/display/metadata/json/... ./cmd/oras/internal/display/content/...reports 0 issuesCo-Authored-By: Claude Opus 4.7 (1M context) [email protected]