mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 00:41:27 -06:00
terraform: another test for count index
This commit is contained in:
parent
ea18b62e8f
commit
88ac1b030a
@ -2487,6 +2487,29 @@ func TestContextPlan_countIndex(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextPlan_countIndexZero(t *testing.T) {
|
||||
m := testModule(t, "plan-count-index-zero")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
ctx := testContext(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
})
|
||||
|
||||
plan, err := ctx.Plan(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := strings.TrimSpace(plan.String())
|
||||
expected := strings.TrimSpace(testTerraformPlanCountIndexZeroStr)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad:\n%s", actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextPlan_countVar(t *testing.T) {
|
||||
m := testModule(t, "plan-count-var")
|
||||
p := testProvider("aws")
|
||||
|
@ -492,6 +492,18 @@ STATE:
|
||||
<no state>
|
||||
`
|
||||
|
||||
const testTerraformPlanCountIndexZeroStr = `
|
||||
DIFF:
|
||||
|
||||
CREATE: aws_instance.foo
|
||||
foo: "" => "0"
|
||||
type: "" => "aws_instance"
|
||||
|
||||
STATE:
|
||||
|
||||
<no state>
|
||||
`
|
||||
|
||||
const testTerraformPlanCountOneIndexStr = `
|
||||
DIFF:
|
||||
|
||||
|
3
terraform/test-fixtures/plan-count-index-zero/main.tf
Normal file
3
terraform/test-fixtures/plan-count-index-zero/main.tf
Normal file
@ -0,0 +1,3 @@
|
||||
resource "aws_instance" "foo" {
|
||||
foo = "${count.index}"
|
||||
}
|
Loading…
Reference in New Issue
Block a user