terraform: another test for count index

This commit is contained in:
Mitchell Hashimoto 2014-10-02 22:07:23 -07:00
parent ea18b62e8f
commit 88ac1b030a
3 changed files with 38 additions and 0 deletions

View File

@ -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")

View File

@ -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:

View File

@ -0,0 +1,3 @@
resource "aws_instance" "foo" {
foo = "${count.index}"
}