test(patch): add unit tests for pkg/patch/multi.go#1577
Merged
omercnet merged 4 commits intoMay 22, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds unit tests for the multi-arch patching orchestration in pkg/patch/multi.go, improving unit-test coverage for multi-platform planning and early validation/error paths without changing production code.
Changes:
- Add table-driven unit tests covering
buildPatchingPlan(including patched tag/reference resolution and invalid-reference fallback). - Add unit tests covering
patchMultiPlatformImageearly-return error paths (missing platforms, unavailable requested platforms, and report-driven discovery parse failure).
This was referenced Apr 30, 2026
418d3b5 to
2f2ce60
Compare
This was referenced May 6, 2026
Adds 8 table-driven and standalone tests covering buildPatchingPlan (100% covered) and the early validation paths of patchMultiPlatformImage in pkg/patch/multi.go (459 LOC, previously had no direct test file — multi-arch patching orchestration was only exercised through integration tests that don't contribute to the unit-test coverage profile). Coverage achieved on multi.go: 51.9% (111/214 statements). Remaining uncovered code is primarily the orchestration body that constructs the buildkit client, drives the gateway, and assembles per-platform manifest descriptors — exercised in the integration/multiarch test suite. Functions tested: - buildPatchingPlan: 5 subtests covering target/preserved separation, all-preserved labelling, explicit patched tag, full registry reference, and invalid-reference fallback. - patchMultiPlatformImage early-return paths: empty platform list, unavailable requested platforms, malformed image reference during report-driven discovery. Patterns mirror pkg/patch/single_test.go and the rest of the package's existing tests: testify require/assert, table-driven, t.Parallel where stateless. No production code changed. Signed-off-by: Omer <omer@descope.com>
2f2ce60 to
97440f4
Compare
sozercan
approved these changes
May 10, 2026
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.
Summary
Adds
pkg/patch/multi_test.go(165 LOC, 8 tests).Achieves 51.9% line coverage on
pkg/patch/multi.go(111/214 statements). Previously zero direct test coverage — multi-arch patching orchestration was only exercised throughintegration/multiarch/tests, which don't contribute to the unit-test coverage profile.No production code changed.
What's tested
buildPatchingPlan: 100% covered, 5 subtests:--patched-tagshort formpatchMultiPlatformImageearly-return paths (3 standalone tests):--platformsavailable in imageWhat's intentionally not tested
The orchestration body — buildkit client construction, gateway driving, per-platform manifest descriptor assembly. Requires live infrastructure; covered by
integration/multiarch/.Test plan
Conventions
Pairs with the
pkg/patch/single.gotest PR — same style:testifyrequire/assert, table-driven,t.Parallel()where stateless.Related
Part of a coverage-improvement series. Other PRs land independently.