Skip to content

[pipedv1][terraform] Add unit tests for executeApplyStage, executePlanStage, and executeRollbackStage #7108

Description

@vishnukothakapu

What would you like to be added:
Three stage-execution functions in the pipedv1 Terraform plugin are marked with // TODO: add test comments but have no unit tests:

  • pkg/app/pipedv1/plugin/terraform/deployment/apply.go:27 - executeApplyStage
  • pkg/app/pipedv1/plugin/terraform/deployment/plan.go:28 - executePlanStage
  • pkg/app/pipedv1/plugin/terraform/deployment/rollback.go:27 - executeRollbackStage

These TODOs were left by the original authors as explicit invitations for contribution. The test infrastructure already exists (plugin_test.go and testdata/ directory in the same package), so no new scaffolding is needed.

Tests should cover at least:

executeApplyStage:

  • Failure when StageLogPersister is unavailable (nil client)
  • Failure when provider.NewTerraformCommand fails (invalid/missing directory)

executePlanStage:

  • Failure when StageLogPersister is unavailable
  • Failure when StageConfig JSON is invalid
  • StageStatusExited when plan shows no changes and ExitOnNoChanges: true
  • StageStatusSuccess when plan shows no changes and ExitOnNoChanges: false

executeRollbackStage:

  • Failure when StageLogPersister is unavailable
  • StageStatusFailure when RunningDeploymentSource.CommitHash is empty (first deployment guard)
  • Failure when provider.NewTerraformCommand fails

Why is this needed:

These functions are core to the Terraform plugin's deployment lifecycle but are completely untested. Adding tests here improves confidence in the pipedv1 plugin architecture and aligns with the project's existing testing patterns already seen in plugin_test.go.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions