terraform: test case for variable count
This commit is contained in:
parent
35352a2746
commit
bf7c40d115
|
@ -1203,6 +1203,35 @@ func TestContextApply_countTainted(t *testing.T) {
|
|||
t.Fatalf("bad: \n%s", actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextApply_countVariable(t *testing.T) {
|
||||
m := testModule(t, "apply-count-variable")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
ctx := testContext(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
})
|
||||
|
||||
if _, err := ctx.Plan(nil); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
state, err := ctx.Apply()
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := strings.TrimSpace(state.String())
|
||||
expected := strings.TrimSpace(testTerraformApplyCountVariableStr)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad: \n%s", actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextApply_module(t *testing.T) {
|
||||
m := testModule(t, "apply-module")
|
||||
p := testProvider("aws")
|
||||
|
|
|
@ -228,6 +228,17 @@ const testTerraformApplyCountTaintedStr = `
|
|||
<no state>
|
||||
`
|
||||
|
||||
const testTerraformApplyCountVariableStr = `
|
||||
aws_instance.foo.0:
|
||||
ID = foo
|
||||
foo = foo
|
||||
type = aws_instance
|
||||
aws_instance.foo.1:
|
||||
ID = foo
|
||||
foo = foo
|
||||
type = aws_instance
|
||||
`
|
||||
|
||||
const testTerraformApplyMinimalStr = `
|
||||
aws_instance.bar:
|
||||
ID = foo
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
variable "foo" {
|
||||
default = "2"
|
||||
}
|
||||
|
||||
resource "aws_instance" "foo" {
|
||||
foo = "foo"
|
||||
count = "${var.foo}"
|
||||
}
|
Loading…
Reference in New Issue