test: add comprehensive test coverage for cmd/oras/internal/display/metadata/text/copy.go#1868
Merged
Conversation
Co-authored-by: TerryHowe <104113+TerryHowe@users.noreply.github.com>
Co-authored-by: TerryHowe <104113+TerryHowe@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add test coverage for cmd/oras/internal/display/metadata/text/copy.go
Add comprehensive test coverage for cmd/oras/internal/display/metadata/text/copy.go
Sep 14, 2025
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1868 +/- ##
==========================================
+ Coverage 85.32% 85.35% +0.02%
==========================================
Files 143 143
Lines 6739 6739
==========================================
+ Hits 5750 5752 +2
+ Misses 703 701 -2
Partials 286 286 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
TerryHowe
requested changes
Sep 14, 2025
Co-authored-by: TerryHowe <104113+TerryHowe@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive test coverage for the CopyHandler implementation in cmd/oras/internal/display/metadata/text/copy.go, which previously had no test coverage.
- Implements 100% function coverage for all public methods (
NewCopyHandler,OnTagged,Render,OnCopied) - Adds thorough test cases covering success paths, error conditions, and edge cases
- Includes integration testing demonstrating typical workflow patterns
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Contributor
|
LoL. @TerryHowe Do you know how to let copilot to address the comments from copilot? |
Member
|
Copilot vs Copilot comments resolved. These type conversions are needed. |
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.
This PR adds complete test coverage for the
CopyHandlerimplementation incmd/oras/internal/display/metadata/text/copy.go. The file previously had no test coverage, which this PR addresses by creatingcopy_test.gowith comprehensive test cases.What's Added
The new test file includes:
TestNewCopyHandler- Tests the constructor function and validates proper interface implementationTestCopyHandler_OnTagged- Tests tag handling with various tag formats (simple, version, complex, empty) plus error scenariosTestCopyHandler_Render- Tests digest rendering with valid descriptors, empty digests, and error conditionsTestCopyHandler_OnCopied- Tests copy operations across different target types:TestCopyHandler_Integration- Demonstrates the typical workflow ofOnCopiedfollowed byRenderTest Coverage
The tests achieve 100% function coverage for all public methods in
copy.go:NewCopyHandler()- 100%OnTagged()- 100%Render()- 100%OnCopied()- 100%Implementation Details
The tests follow established patterns from other test files in the package (
backup_test.go,push_test.go,restore_test.go):errorWriterhelper for testing error conditionsRecent Changes
handler.(metadata.CopyHandler)inTestNewCopyHandlersince the variable is already of that type"oras.land/oras/cmd/oras/internal/display/metadata"All tests pass successfully and maintain consistency with the existing codebase style and testing patterns.
Fixes #1862.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.