add failing test for invalid output with targets

Outputs that are missing references aren't always removed from the
graph, due to being filtered before their dependents are removed.
This commit is contained in:
James Bardin 2018-03-19 20:32:37 -04:00
parent 60bc16305a
commit e5f8adfc1a
3 changed files with 45 additions and 0 deletions

View File

@ -2969,6 +2969,28 @@ STATE:
}
}
// ensure that outputs missing references due to targetting are removed from
// the graph.
func TestContext2Plan_outputContainsTargetedResource(t *testing.T) {
m := testModule(t, "plan-untargeted-resource-output")
p := testProvider("aws")
p.DiffFn = testDiffFn
ctx := testContext2(t, &ContextOpts{
Module: m,
ProviderResolver: ResourceProviderResolverFixed(
map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
),
Targets: []string{"module.mod.aws_instance.a"},
})
_, err := ctx.Plan()
if err != nil {
t.Fatalf("err: %s", err)
}
}
// https://github.com/hashicorp/terraform/issues/4515
func TestContext2Plan_targetedOverTen(t *testing.T) {
m := testModule(t, "plan-targeted-over-ten")

View File

@ -0,0 +1,8 @@
module "mod" {
source = "./mod"
}
resource "aws_instance" "c" {
name = "${module.mod.output}"
}

View File

@ -0,0 +1,15 @@
locals {
"one" = 1
}
resource "aws_instance" "a" {
count = "${local.one}"
}
resource "aws_instance" "b" {
count = "${local.one}"
}
output "output" {
value = "${join("", coalescelist(aws_instance.a.*.id, aws_instance.b.*.id))}"
}