Skip to content

test: verify push display handler calls - #2293

Merged
TerryHowe merged 16 commits into
oras-project:mainfrom
TanvirTian:test/display-handler-calls
Nov 1, 2026
Merged

TerryHowe merged 16 commits into
oras-project:mainfrom
TanvirTian:test/display-handler-calls

Conversation

@TanvirTian

@TanvirTian TanvirTian commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
This PR updates the display handler tests to check handler calls instead of printed output.

It adds shared test helpers to record handler calls and updates the affected command tests to use them. This makes the tests easier to read and check.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fix #2281

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?

@codecov

codecov Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.39394% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.40%. Comparing base (bc7b32d) to head (5266792).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
cmd/oras/internal/display/displaytest/backup.go 70.00% 9 Missing ⚠️
cmd/oras/internal/display/displaytest/pull.go 85.71% 3 Missing ⚠️
cmd/oras/internal/display/displaytest/restore.go 88.88% 3 Missing ⚠️
cmd/oras/root/repo/ls.go 75.00% 2 Missing and 1 partial ⚠️
cmd/oras/root/attach.go 50.00% 1 Missing ⚠️
cmd/oras/root/backup.go 50.00% 1 Missing ⚠️
cmd/oras/root/blob/delete.go 50.00% 1 Missing ⚠️
cmd/oras/root/discover.go 66.66% 1 Missing ⚠️
cmd/oras/root/manifest/delete.go 50.00% 1 Missing ⚠️
cmd/oras/root/manifest/push.go 91.66% 1 Missing ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2293      +/-   ##
==========================================
+ Coverage   61.85%   70.40%   +8.54%     
==========================================
  Files         140      154      +14     
  Lines        6098     6329     +231     
==========================================
+ Hits         3772     4456     +684     
+ Misses       2102     1607     -495     
- Partials      224      266      +42     

☔ 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.

@TanvirTian

Copy link
Copy Markdown
Contributor Author

Hey @TerryHowe , I've updated this PR and will work on the remaining tasks. Feel free to share any feedback or review. Thanks!

@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.

Issue #2281: shared recording fakes package (display/displaytest) is not addressed.
Issue #2281: unit tests for uncovered metadata/text, status text/tty and discard handlers are not addressed.
Issue #2281: converting remaining commands and migrating output assertions out of pull_test.go, manifest/fetch_test.go, cp_test.go is not addressed.
Issue #2281 is only partly fixed — use "Refs #2281" or finish the remaining plan items.

Comment thread cmd/oras/root/push_test.go Resolved
Comment thread cmd/oras/root/push_test.go Resolved
Comment thread cmd/oras/root/push_test.go Resolved
Comment thread cmd/oras/root/push.go Resolved
Comment thread cmd/oras/root/push.go Resolved
@TanvirTian
TanvirTian force-pushed the test/display-handler-calls branch from 346897d to 659c706 Compare October 24, 2026 16:28
@TanvirTian
TanvirTian marked this pull request as ready for review October 25, 2026 11:47
@TanvirTian

Copy link
Copy Markdown
Contributor Author

@TerryHowe , the PR is ready for review. Please let me know if there are is any issues. Thanks 🐈

@TanvirTian

Copy link
Copy Markdown
Contributor Author

I’m doing a final pass against the original issue to verify a few remaining items around command injection seams and factory test coverage. I’ll address any confirmed gaps and wrap things up shortly.

Comment thread cmd/oras/root/attach.go Resolved
Comment thread cmd/oras/root/attach_test.go Resolved
Comment thread cmd/oras/root/attach_test.go Resolved
Comment thread cmd/oras/root/backup_test.go Resolved
Comment thread cmd/oras/root/backup_test.go Resolved
Comment thread cmd/oras/root/manifest/push_test.go Resolved
Comment thread cmd/oras/root/discover_test.go Resolved
Comment thread cmd/oras/root/push.go Resolved
Comment thread cmd/oras/root/push.go Resolved
@TanvirTian
TanvirTian force-pushed the test/display-handler-calls branch from c83879f to ad10760 Compare October 25, 2026 20:22
@TanvirTian
TanvirTian force-pushed the test/display-handler-calls branch from ad10760 to a6c4ca8 Compare October 25, 2026 20:24
@TanvirTian

Copy link
Copy Markdown
Contributor Author

Hi @TerryHowe, I've made the changes you asked for and updated the tests. Thanks for your feedback 🐕

Replace the optional `injected ...X` parameters and newXHandler(s)
dispatch helpers with doX(ctx, ..., statusHandler, metadataHandler)
functions that runX calls after building the real handlers. Tests call
doX directly with displaytest fakes.

- attach, backup, restore, discover, repo ls, repo tags and manifest
  push get new doX helpers; tag, resolve, blob delete and manifest
  delete rename their existing helpers to doX
- backup and restore tests now run a real backup from an in-memory
  source and a real restore from a tar, asserting the handler call order
- drop tests that only exercised fakes or the removed dispatch helpers;
  handler_test.go already covers the display factories
- move the manifest delete and repo ls recorders into displaytest
- assert only the stable start and end of the attach call sequence
- restore a blank line in push.go removed as unrelated churn

Signed-off-by: Terry Howe <[email protected]>
Add unit tests for the status handlers that had no coverage:

- text: manifest push, blob push, manifest index create and update,
  TrackTarget for push and pull, Start/StopTracking for copy and blob
  push, and the attach handler constructor
- tty: push OnCopySkipped and PreCopy, pull OnNodeRestored and
  OnNodeSkipped, backup and restore StopTracking, and the blob push
  handler

The tty tests use a recording tracked target, so they check which
progress state each handler reports instead of only checking for nil
errors. Coverage of the status package goes from 73.3% to 93.6%.

Signed-off-by: Terry Howe <[email protected]>

@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

Blob delete now requires the reference to be a digest (oras-project#2304), so the
placeholder references sha256:missing and sha256:1234 fail validation
before the handler is called. Use real digests instead.

Signed-off-by: Terry Howe <[email protected]>
@TerryHowe
TerryHowe merged commit 1cc414e into oras-project:main Nov 1, 2026
10 checks passed
@TerryHowe TerryHowe mentioned this pull request Nov 17, 2026
4 tasks done
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.

test: verify display handler calls in command tests instead of rendered output

2 participants