Skip to content

Commit a4850a8

Browse files
committed
Add 'AdditionalCLIOptions.PlanOptions.NoRefresh' to test 'terraform plan -refresh=false'.
1 parent 11b98cd commit a4850a8

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

helper/resource/additional_cli_options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ type ApplyOptions struct {
2323
type PlanOptions struct {
2424
// AllowDeferral will pass the experimental `-allow-deferral` flag to the plan command.
2525
AllowDeferral bool
26+
27+
// NoRefresh will pass the `-refresh=false` flag to the plan command.
28+
NoRefresh bool
2629
}

helper/resource/testing_new_config.go

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,13 @@ func testStepNewConfig(ctx context.Context, t testing.T, c TestCase, wd *plugint
108108
opts = append(opts, tfexec.Destroy(true))
109109
}
110110

111-
if c.AdditionalCLIOptions != nil && c.AdditionalCLIOptions.Plan.AllowDeferral {
112-
opts = append(opts, tfexec.AllowDeferral(true))
111+
if c.AdditionalCLIOptions != nil {
112+
if c.AdditionalCLIOptions.Plan.AllowDeferral {
113+
opts = append(opts, tfexec.AllowDeferral(true))
114+
}
115+
if c.AdditionalCLIOptions.Plan.NoRefresh {
116+
opts = append(opts, tfexec.Refresh(false))
117+
}
113118
}
114119

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

253-
if c.AdditionalCLIOptions != nil && c.AdditionalCLIOptions.Plan.AllowDeferral {
254-
opts = append(opts, tfexec.AllowDeferral(true))
258+
if c.AdditionalCLIOptions != nil {
259+
if c.AdditionalCLIOptions.Plan.AllowDeferral {
260+
opts = append(opts, tfexec.AllowDeferral(true))
261+
}
262+
if c.AdditionalCLIOptions.Plan.NoRefresh {
263+
opts = append(opts, tfexec.Refresh(false))
264+
}
255265
}
256266

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

322-
if c.AdditionalCLIOptions != nil && c.AdditionalCLIOptions.Plan.AllowDeferral {
323-
opts = append(opts, tfexec.AllowDeferral(true))
332+
if c.AdditionalCLIOptions != nil {
333+
if c.AdditionalCLIOptions.Plan.AllowDeferral {
334+
opts = append(opts, tfexec.AllowDeferral(true))
335+
}
336+
if c.AdditionalCLIOptions.Plan.NoRefresh {
337+
opts = append(opts, tfexec.Refresh(false))
338+
}
324339
}
325340

326341
return wd.CreatePlan(ctx, opts...)

0 commit comments

Comments
 (0)