Skip to content

test: add coverage for display content and json handlers - #1950

Merged
TerryHowe merged 4 commits into
oras-project:mainfrom
bimakw:test/display-coverage
May 24, 2026
Merged

TerryHowe merged 4 commits into
oras-project:mainfrom
bimakw:test/display-coverage

Conversation

@bimakw

@bimakw bimakw commented Dec 26, 2025

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
Add test coverage for display packages that currently have 0% coverage.

Files covered:

  • content/discard.go: Tests for DiscardHandler methods (OnContentFetched, OnContentCreated)
  • metadata/json/push.go: Tests for PushHandler methods (OnTagged, OnCopied, Render)
  • metadata/json/pull.go: Tests for PullHandler methods (OnLayerSkipped, OnFilePulled, OnPulled, Render)

Which issue(s) this PR fixes:
Partial: #1916

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?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds initial test coverage for three display package files that previously had 0% coverage: discard.go, push.go, and pull.go in the display metadata/content packages.

Key changes:

  • Adds unit tests for DiscardHandler methods (OnContentFetched, OnContentCreated) and interface compliance
  • Adds unit tests for JSON PushHandler methods (OnTagged, OnCopied, Render) covering both tag and digest reference scenarios
  • Adds unit tests for JSON PullHandler methods (OnLayerSkipped, OnFilePulled, OnPulled, Render)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
cmd/oras/internal/display/metadata/json/push_test.go Adds comprehensive tests for PushHandler including constructor, event handlers (OnTagged, OnCopied), and JSON rendering with both tag and digest references
cmd/oras/internal/display/metadata/json/pull_test.go Adds tests for PullHandler covering constructor, layer skipping, file pulling, and JSON output rendering
cmd/oras/internal/display/content/discard_test.go Adds tests for DiscardHandler verifying no-op behavior and interface compliance

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add test coverage for:
- content/discard.go: DiscardHandler methods
- metadata/json/push.go: PushHandler methods
- metadata/json/pull.go: PullHandler methods

Partial: oras-project#1916

Signed-off-by: Gregorius Bima Kharisma Wicaksana <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions Bot added the stale Inactive issues or pull requests label Feb 10, 2026
@bimakw

bimakw commented Feb 10, 2026

Copy link
Copy Markdown
Contributor Author

still working on this, will address the review comments soon

@github-actions github-actions Bot removed the stale Inactive issues or pull requests label Feb 11, 2026
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions Bot added the stale Inactive issues or pull requests label Mar 29, 2026
@TerryHowe TerryHowe removed the stale Inactive issues or pull requests label Apr 15, 2026
@TerryHowe
TerryHowe requested a review from sabre1041 as a code owner April 15, 2026 00:57

@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

@codecov

codecov Bot commented May 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.22%. Comparing base (33c9281) to head (a564d20).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1950      +/-   ##
==========================================
- Coverage   87.25%   87.22%   -0.04%     
==========================================
  Files         138      138              
  Lines        5462     5462              
==========================================
- Hits         4766     4764       -2     
- Misses        415      417       +2     
  Partials      281      281              

☔ View full report in Codecov by Sentry.
📢 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.

fix

Signed-off-by: Terry Howe <[email protected]>
@TerryHowe
TerryHowe merged commit a9b45e3 into oras-project:main May 24, 2026
1 check passed
TerryHowe added a commit to TerryHowe/oras that referenced this pull request May 24, 2026
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 added a commit to TerryHowe/oras that referenced this pull request Jun 28, 2026
…t#1950)

Signed-off-by: Gregorius Bima Kharisma Wicaksana <[email protected]>
Signed-off-by: Terry Howe <[email protected]>
Co-authored-by: Terry Howe <[email protected]>
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.

3 participants