Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/unreleased/ENHANCEMENTS-20250421-145039.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: ENHANCEMENTS
body: Adds `AdditionalCLIOptions.PlanOptions.NoRefresh` to test `terraform plan -refresh=false`
time: 2025-04-21T14:50:39.764057-04:00
custom:
Issue: "490"
3 changes: 3 additions & 0 deletions helper/resource/additional_cli_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ type ApplyOptions struct {
type PlanOptions struct {
// AllowDeferral will pass the experimental `-allow-deferral` flag to the plan command.
AllowDeferral bool

// NoRefresh will pass the `-refresh=false` flag to the plan command.
NoRefresh bool
}
27 changes: 21 additions & 6 deletions helper/resource/testing_new_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ func testStepNewConfig(ctx context.Context, t testing.T, c TestCase, wd *plugint
opts = append(opts, tfexec.Destroy(true))
}

if c.AdditionalCLIOptions != nil && c.AdditionalCLIOptions.Plan.AllowDeferral {
opts = append(opts, tfexec.AllowDeferral(true))
if c.AdditionalCLIOptions != nil {
if c.AdditionalCLIOptions.Plan.AllowDeferral {
opts = append(opts, tfexec.AllowDeferral(true))
}
if c.AdditionalCLIOptions.Plan.NoRefresh {
opts = append(opts, tfexec.Refresh(false))
}
}

return wd.CreatePlan(ctx, opts...)
Expand Down Expand Up @@ -250,8 +255,13 @@ func testStepNewConfig(ctx context.Context, t testing.T, c TestCase, wd *plugint
opts = append(opts, tfexec.Destroy(true))
}

if c.AdditionalCLIOptions != nil && c.AdditionalCLIOptions.Plan.AllowDeferral {
opts = append(opts, tfexec.AllowDeferral(true))
if c.AdditionalCLIOptions != nil {
if c.AdditionalCLIOptions.Plan.AllowDeferral {
opts = append(opts, tfexec.AllowDeferral(true))
}
if c.AdditionalCLIOptions.Plan.NoRefresh {
opts = append(opts, tfexec.Refresh(false))
}
}

return wd.CreatePlan(ctx, opts...)
Expand Down Expand Up @@ -319,8 +329,13 @@ func testStepNewConfig(ctx context.Context, t testing.T, c TestCase, wd *plugint
}
}

if c.AdditionalCLIOptions != nil && c.AdditionalCLIOptions.Plan.AllowDeferral {
opts = append(opts, tfexec.AllowDeferral(true))
if c.AdditionalCLIOptions != nil {
if c.AdditionalCLIOptions.Plan.AllowDeferral {
opts = append(opts, tfexec.AllowDeferral(true))
}
if c.AdditionalCLIOptions.Plan.NoRefresh {
opts = append(opts, tfexec.Refresh(false))
}
}

return wd.CreatePlan(ctx, opts...)
Expand Down
Loading