Repository navigation
test(display): cover the raw content handlers - #2182
Merged
TerryHowe merged 1 commit intoSep 21, 2026
Merged
Conversation
The content package sits at 37.9% of statements. manifest_fetch.go had no
test file at all, so neither of its functions was exercised, and
manifest_index.go was covered only on the path where creating the output
file fails.
These handlers write what `oras manifest fetch` and `oras manifest index
create` put on stdout or into --output, so a change in them is immediately
visible to users but was caught by almost nothing.
Add manifest_fetch_test.go and extend manifest_index_test.go, asserting the
bytes that come out rather than only that no error is returned:
- --pretty is dropped when the output is a file and kept for stdout and
for "-", which is the documented intent of both constructors but was
pinned by nothing
- the compact form is byte-for-byte the fetched content, so it stays
pipeable, while only the pretty form is indented
- writing to --output puts the content in the file and leaves stdout
untouched
- a path that cannot be created reports "failed to open", a failing
writer surfaces its error, and content that is not JSON fails while
prettifying rather than being written out half-formed
Coverage goes from 37.9% to 100.0% of statements, with every function in
the package at 100%. No production code is changed.
Signed-off-by: Akshita <[email protected]>
akshita317
requested review from
TerryHowe,
Wwwsylvia,
sabre1041,
sajayantony and
shizhMSFT
as code owners
September 21, 2026 12:58
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2182 +/- ##
==========================================
+ Coverage 87.81% 87.89% +0.07%
==========================================
Files 139 139
Lines 5689 5691 +2
==========================================
+ Hits 4996 5002 +6
+ Misses 413 411 -2
+ Partials 280 278 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
Thanks! |
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.
Problem
cmd/oras/internal/display/contentis at 37.9% of statements.manifest_fetch.gohas no test file at all — neither of its functions is exercised — andmanifest_index.gois covered only on the path where creating the output file fails.These handlers produce what
oras manifest fetchandoras manifest index createwrite to stdout or to--output, so a regression is immediately visible to users but was caught by almost nothing.Changes
manifest_fetch_test.go(new, pairing 1:1 with its source) and additional cases inmanifest_index_test.go. The existing index test is unchanged. Assertions are on the bytes that come out, not merely that no error is returned:--prettyis dropped for a file and kept for stdout and for-. Both constructors do this deliberately (// ignore --pretty when output to a file) but nothing pinned it, so the behaviour could have been lost silently.--outputwrites to the file and leaves stdout untouched.failed to open, a failing writer surfaces its error, and content that is not JSON fails while prettifying rather than being written out half-formed.Result
Every function in the package is now at 100%:
No production code is changed.
go test ./...,gofmtandgo vetare clean.