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:
parent
60bc16305a
commit
e5f8adfc1a
|
@ -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")
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
module "mod" {
|
||||
source = "./mod"
|
||||
}
|
||||
|
||||
|
||||
resource "aws_instance" "c" {
|
||||
name = "${module.mod.output}"
|
||||
}
|
|
@ -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))}"
|
||||
}
|
Loading…
Reference in New Issue