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.
This commit is contained in:
James Nugent 2016-06-23 21:11:36 +01:00
parent 17f4777039
commit 983e4f13c6
4 changed files with 40 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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