core: Add context test for empty lists as module outputs

This test illustrates a failure which occurs during the Input walk, if
an interpolation is used with the input of a splat operation resulting
in a multi-variable.

The bug was found during use of the RC2, but does not correspond to an
open issue at present.
pull/7304/head
James Nugent 10 years ago
parent 17f4777039
commit 983e4f13c6

@ -49,6 +49,27 @@ func TestContext2Input(t *testing.T) {
}
}
func TestContext2Input_moduleComputedOutputElement(t *testing.T) {
m := testModule(t, "input-module-computed-output-element")
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
ctx := testContext2(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
})
p.InputFn = func(i UIInput, c *ResourceConfig) (*ResourceConfig, error) {
return c, nil
}
if err := ctx.Input(InputModeStd); err != nil {
t.Fatalf("err: %s", err)
}
}
func TestContext2Input_badVarDefault(t *testing.T) {
m := testModule(t, "input-bad-var-default")
p := testProvider("aws")

@ -0,0 +1,9 @@
module "b" {
source = "./modb"
}
module "a" {
source = "./moda"
single_element = "${element(module.b.computed_list, 0)}"
}

@ -0,0 +1,3 @@
variable "single_element" {
type = "string"
}

@ -0,0 +1,7 @@
resource "aws_instance" "test" {
count = 3
}
output "computed_list" {
value = ["${aws_instance.test.*.id}"]
}
Loading…
Cancel
Save