Skip to content

test(display): cover the remaining JSON metadata handlers - #2266

Merged
TerryHowe merged 1 commit into
oras-project:mainfrom
akshita317:test/display-json-handlers
Oct 21, 2026
Merged

TerryHowe merged 1 commit into
oras-project:mainfrom
akshita317:test/display-json-handlers

Conversation

@akshita317

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Adds tests for the five JSON metadata handlers in cmd/oras/internal/display/metadata/json that had none: attach, discover, manifest fetch, repo ls and repo tags. The tests check the rendered JSON, including:

  • a nested referrer tree from discover, and an error for a referrer whose subject was never discovered
  • manifest fetch embedding JSON content, and reporting non-JSON content as null
  • empty repository and tag lists rendered as [] rather than null

This raises coverage of the package from 41.2% to 100%. Test-only change, following the earlier test(display) PRs.

Which issue(s) this PR fixes:

N/A

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

Add tests for the attach, discover, manifest fetch, repo ls and repo
tags JSON handlers, which had none. They check the rendered output,
including a nested referrer tree, a referrer whose subject was never
discovered, non-JSON manifest content reported as null, and empty
repository and tag lists rendered as [] rather than null.

This raises coverage of display/metadata/json from 41.2% to 100%.

Signed-off-by: Akshita <[email protected]>
@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.66%. Comparing base (38812fe) to head (e94e757).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2266      +/-   ##
==========================================
+ Coverage   60.08%   60.66%   +0.57%     
==========================================
  Files         140      140              
  Lines        6091     6091              
==========================================
+ Hits         3660     3695      +35     
+ Misses       2209     2174      -35     
  Partials      222      222              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@TerryHowe
TerryHowe merged commit ed26899 into oras-project:main Oct 21, 2026
10 checks passed
@TerryHowe

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants