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

未关闭
#7,108 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@akshat-lakhera 已经在做这个了。

开始于 2026年10月17日。

  • #7109 来自 @vishnukothakapu —— 已关闭,未合并

评估

难度
3/5
预计耗时
1-2 天
新手友好度
76/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
冷清
技术栈
go, terraform
领域
devops, testing-qa

调研方向

先从 pkg/app/pipedv1/plugin/terraform/deployment/apply.go、plan.go 和 rollback.go 中的 TODO 位置开始,然后阅读 plugin_test.go 和 package 的 testdata 目录。遵循现有的测试基础设施,为列出的失败和状态场景添加单元测试。所有指定场景都已覆盖且 package 测试通过,即表示完成。

由索引模型根据 Issue 内容生成。

描述

kind/enhancement

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.

主要语言
Go
星标
1.4k
派生
391
平均合并
4 天 1 小时
30 天内合并 PR
58

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pipe-cd/pipecd 的其他 Issue

查看 pipe-cd/pipecd 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。