TransformTargets cannot depends on knowing Destroy

There is no reliable way to know if `destroy` was called from the cli.
This commit is contained in:
James Bardin 2020-06-10 15:38:35 -04:00
parent aa7e6f8d86
commit a2d8376eeb
1 changed files with 0 additions and 52 deletions

View File

@ -200,55 +200,3 @@ output.grandchild_id (expand)
t.Fatalf("bad:\n\nexpected:\n%s\n\ngot:\n%s\n", expected, actual) t.Fatalf("bad:\n\nexpected:\n%s\n\ngot:\n%s\n", expected, actual)
} }
} }
func TestTargetsTransformer_destroy(t *testing.T) {
mod := testModule(t, "transform-targets-destroy")
g := Graph{Path: addrs.RootModuleInstance}
{
tf := &ConfigTransformer{Config: mod}
if err := tf.Transform(&g); err != nil {
t.Fatalf("err: %s", err)
}
}
{
transform := &AttachResourceConfigTransformer{Config: mod}
if err := transform.Transform(&g); err != nil {
t.Fatalf("err: %s", err)
}
}
{
transform := &ReferenceTransformer{}
if err := transform.Transform(&g); err != nil {
t.Fatalf("err: %s", err)
}
}
{
transform := &TargetsTransformer{
Targets: []addrs.Targetable{
addrs.RootModuleInstance.Resource(
addrs.ManagedResourceMode, "aws_instance", "me",
),
},
Destroy: true,
}
if err := transform.Transform(&g); err != nil {
t.Fatalf("err: %s", err)
}
}
actual := strings.TrimSpace(g.String())
expected := strings.TrimSpace(`
aws_elb.me
aws_instance.me
aws_instance.me
aws_instance.metoo
aws_instance.me
`)
if actual != expected {
t.Fatalf("bad:\n\nexpected:\n%s\n\ngot:\n%s\n", expected, actual)
}
}