core: Another validate test for computed module var refs

I wanted to make sure this case was handled, and it is!

So here's an extra test for us.
This commit is contained in:
Paul Hinze 2016-05-23 15:54:14 -05:00
parent ed042ab067
commit b205ac2123
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
4 changed files with 43 additions and 0 deletions

View File

@ -776,3 +776,30 @@ func TestContext2Validate_interpolateVar(t *testing.T) {
t.Fatal("err:", e)
}
}
// When module vars reference something that is actually computed, this
// shouldn't cause validation to fail.
func TestContext2Validate_interpolateComputedModuleVarDef(t *testing.T) {
input := new(MockUIInput)
m := testModule(t, "validate-computed-module-var-ref")
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
ctx := testContext2(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
UIInput: input,
})
w, e := ctx.Validate()
if w != nil {
t.Log("warnings:", w)
}
if e != nil {
t.Fatal("err:", e)
}
}

View File

@ -0,0 +1,5 @@
variable "destin" { }
resource "aws_instance" "dest" {
attr = "${var.destin}"
}

View File

@ -0,0 +1,8 @@
module "source" {
source = "./source"
}
module "dest" {
source = "./dest"
destin = "${module.source.sourceout}"
}

View File

@ -0,0 +1,3 @@
resource "aws_instance" "source" { }
output "sourceout" { value = "${aws_instance.source.id}" }