diff --git a/terraform/test-fixtures/transform-destroy-edge-multi/main.tf b/terraform/test-fixtures/transform-destroy-edge-multi/main.tf new file mode 100644 index 0000000000..93e8211ca4 --- /dev/null +++ b/terraform/test-fixtures/transform-destroy-edge-multi/main.tf @@ -0,0 +1,3 @@ +resource "test" "A" {} +resource "test" "B" { value = "${test.A.value}" } +resource "test" "C" { value = "${test.B.value}" } diff --git a/terraform/transform_destroy_edge_test.go b/terraform/transform_destroy_edge_test.go index 49b2552be3..5d124bfc86 100644 --- a/terraform/transform_destroy_edge_test.go +++ b/terraform/transform_destroy_edge_test.go @@ -23,6 +23,25 @@ func TestDestroyEdgeTransformer(t *testing.T) { } } +func TestDestroyEdgeTransformer_multi(t *testing.T) { + g := Graph{Path: RootModulePath} + g.Add(&graphNodeDestroyerTest{AddrString: "test.A"}) + g.Add(&graphNodeDestroyerTest{AddrString: "test.B"}) + g.Add(&graphNodeDestroyerTest{AddrString: "test.C"}) + tf := &DestroyEdgeTransformer{ + Module: testModule(t, "transform-destroy-edge-multi"), + } + if err := tf.Transform(&g); err != nil { + t.Fatalf("err: %s", err) + } + + actual := strings.TrimSpace(g.String()) + expected := strings.TrimSpace(testTransformDestroyEdgeMultiStr) + if actual != expected { + t.Fatalf("bad:\n\n%s", actual) + } +} + type graphNodeDestroyerTest struct { AddrString string } @@ -42,3 +61,11 @@ test.A (destroy) test.B (destroy) test.B (destroy) ` + +const testTransformDestroyEdgeMultiStr = ` +test.A (destroy) + test.B (destroy) +test.B (destroy) + test.C (destroy) +test.C (destroy) +`