From 08dade547519319befd4a169e0d80179ef3f4660 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 20 Sep 2016 10:18:31 -0700 Subject: [PATCH] terraform: more destroy edge tests --- .../transform-destroy-edge-multi/main.tf | 3 +++ terraform/transform_destroy_edge_test.go | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 terraform/test-fixtures/transform-destroy-edge-multi/main.tf 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) +`