terraform: more destroy edge tests

This commit is contained in:
Mitchell Hashimoto 2016-09-20 10:18:31 -07:00
parent 7b2bd93094
commit 08dade5475
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,3 @@
resource "test" "A" {}
resource "test" "B" { value = "${test.A.value}" }
resource "test" "C" { value = "${test.B.value}" }

View File

@ -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)
`