Skip to content

test(patch): add unit tests for pkg/patch/multi.go#1577

Merged
omercnet merged 4 commits into
project-copacetic:mainfrom
omercnet:coverage/pr5-test-multi
May 22, 2026
Merged

test(patch): add unit tests for pkg/patch/multi.go#1577
omercnet merged 4 commits into
project-copacetic:mainfrom
omercnet:coverage/pr5-test-multi

Conversation

@omercnet
Copy link
Copy Markdown
Contributor

@omercnet omercnet commented Apr 30, 2026

Part of the coverage-improvement series tracked in #1580.

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 through integration/multiarch/ tests, which don't contribute to the unit-test coverage profile.

No production code changed.

What's tested

  • buildPatchingPlan: 100% covered, 5 subtests:
    • target / preserved platform separation
    • all-preserved → "all platforms" labelling
    • explicit --patched-tag short form
    • full registry image reference passthrough
    • invalid-reference fallback to simple suffix
  • patchMultiPlatformImage early-return paths (3 standalone tests):
    • empty platform list
    • none of --platforms available in image
    • malformed image reference during report-driven discovery

What'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

go test ./pkg/patch/... -count=1               # ok
go vet ./pkg/patch/...                          # clean
gofumpt -l pkg/patch/multi_test.go              # clean

Conventions

Pairs with the pkg/patch/single.go test PR — same style: testify require/assert, table-driven, t.Parallel() where stateless.

Related

Part of a coverage-improvement series. Other PRs land independently.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 patchMultiPlatformImage early-return error paths (missing platforms, unavailable requested platforms, and report-driven discovery parse failure).

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>
@omercnet omercnet force-pushed the coverage/pr5-test-multi branch from 2f2ce60 to 97440f4 Compare May 8, 2026 17:52
@omercnet omercnet enabled auto-merge (squash) May 22, 2026 17:54
@omercnet omercnet merged commit 1bbaa77 into project-copacetic:main May 22, 2026
10 of 13 checks passed
@github-project-automation github-project-automation Bot moved this from 🆕 New to ✅ Done in Copacetic Workboard May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants