Skip to content

test(planpreview): add unit tests for builder.buildApp - #7665

Open
Atharva-Ramawat wants to merge 3 commits into
pipe-cd:masterfrom
Atharva-Ramawat:test/planpreview-build-app
Open

Atharva-Ramawat wants to merge 3 commits into
pipe-cd:masterfrom
Atharva-Ramawat:test/planpreview-build-app

Conversation

@Atharva-Ramawat

Copy link
Copy Markdown
Contributor

What this PR does:

Adds unit tests for (*builder).buildApp in pkg/app/pipedv1/planpreview/builder_test.go and removes the resolved // TODO: add tests comment in pkg/app/pipedv1/planpreview/builder.go.

Covered scenarios:

  • Non-NotFound error when fetching the last successful deployment
  • Failure when getting the target deploy source
  • Failure when the target application config is invalid
  • Failure when retrieving plugin clients from the registry
  • First deployment (codes.NotFound) succeeding with QUICK_SYNC and nil running deploy source
  • Subsequent deployment passing the running deploy source and skipping plugins that return codes.Unimplemented
  • Error aggregation when plugin.GetPlanPreview returns an error
  • Fallback PluginNames = []string{"<unknown>"} when no plugins execute

Why we need it:

pkg/app/pipedv1/planpreview/builder_test.go previously only covered listApplications, leaving buildApp untested.

Which issue(s) this PR fixes:

Fixes #7664

Does this PR introduce a user-facing change?:

No.

  • How are users affected by this change: N/A
  • Is this breaking change: No
  • How to migrate (if breaking change): N/A

Screenshots/Videos (for documentation or website changes):

N/A

Signed-off-by: Atharva Ramawat <atharvaramawat027@gmail.com>
@Atharva-Ramawat
Atharva-Ramawat requested review from a team as code owners November 23, 2026 19:36
@Atharva-Ramawat
Atharva-Ramawat requested review from Warashi, mohammedfirdouss and t-kikuc and a balanced review from Copilot November 23, 2026 19:36
@netlify

netlify Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

👷 Deploy request for pipecd-site pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit b718517

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.

🟡 Changes recommended

The test covers only one failing plugin, leaving error aggregation unprotected; it should verify that failures from two distinct plugins both appear in res.Error.

1 open issue
What changed in this PR

Adds unit tests for the pipedv1 plan-preview builder, addressing #7664 without changing runtime behavior.

Changes:

  • Adds test doubles for API, plugin, and Git interactions.
  • Covers deployment-source failures, first and subsequent deployments, plugin errors, unsupported plugins, and fallback plugin names.
  • Removes the buildApp testing TODO comment.
File Description
pkg/​app/​pipedv1/​planpreview/​builder.go Removes the testing TODO comment; no functional changes.
pkg/​app/​pipedv1/​planpreview/​builder_test.go Adds test helpers and seven buildApp scenarios.

Review effort: Balanced

…lugins

Signed-off-by: Atharva Ramawat <atharvaramawat027@gmail.com>

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.

🔵 Needs a closer look

The tests do not exercise plugin-selected strategies because the configuration has no pipeline stages, leaving a regression that always selects QUICK_SYNC undetected.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Add pipeline strategy propagation test

pkg/​app/​pipedv1/​planpreview/​builder_test.go:382

These strategy responses are never exercised: validAppConfig has no pipeline stages, so controller.DetermineStrategy returns QUICK_SYNC before calling either plugin. The suite therefore does not detect a regression where buildApp always selects QUICK_SYNC instead of propagating the plugin-selected strategy. Please add a pipeline-configured subsequent-deployment case with a plugin returning PIPELINE, and assert that DetermineStrategy is called and that res.SyncStrategy matches its response.

1 resolved since last review

Review effort: Balanced

Signed-off-by: Atharva Ramawat <atharvaramawat027@gmail.com>

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.

🔵 Needs a closer look

The test omits assertions for res.NoChange, allowing an aggregation bug that updates the plugin response instead of the application result to pass undetected.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Propagate plugin NoChange status to the application result

pkg/​app/​pipedv1/​planpreview/​builder_test.go:435

The active plugin returns NoChange: true, but this test never checks res.NoChange. It therefore passes despite buildApp leaving that field false: builder.go:308 updates the plugin response instead of the application result. Please assert that the unchanged-only result has NoChange == true, add a corresponding false assertion for the changed-result fixture, and correct the aggregation so these assertions pass.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit tests for pipedv1 planpreview builder.buildApp

2 participants