2016-09-21 12:55:07 -05:00
|
|
|
package terraform
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCBDEdgeTransformer(t *testing.T) {
|
|
|
|
g := Graph{Path: RootModulePath}
|
2016-09-21 13:33:47 -05:00
|
|
|
g.Add(&graphNodeCreatorTest{AddrString: "test.A"})
|
2016-09-21 15:54:19 -05:00
|
|
|
g.Add(&graphNodeCreatorTest{AddrString: "test.B"})
|
2016-09-21 13:33:47 -05:00
|
|
|
g.Add(&graphNodeDestroyerTest{AddrString: "test.A", CBD: true})
|
2016-09-21 12:55:07 -05:00
|
|
|
|
2016-09-21 18:37:41 -05:00
|
|
|
module := testModule(t, "transform-destroy-edge-basic")
|
|
|
|
|
2016-09-21 12:55:07 -05:00
|
|
|
{
|
|
|
|
tf := &DestroyEdgeTransformer{
|
2016-09-21 18:37:41 -05:00
|
|
|
Module: module,
|
2016-09-21 12:55:07 -05:00
|
|
|
}
|
|
|
|
if err := tf.Transform(&g); err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2016-09-21 18:37:41 -05:00
|
|
|
tf := &CBDEdgeTransformer{Module: module}
|
2016-09-21 12:55:07 -05:00
|
|
|
if err := tf.Transform(&g); err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
actual := strings.TrimSpace(g.String())
|
|
|
|
expected := strings.TrimSpace(testTransformCBDEdgeBasicStr)
|
|
|
|
if actual != expected {
|
|
|
|
t.Fatalf("bad:\n\n%s", actual)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const testTransformCBDEdgeBasicStr = `
|
2016-09-21 13:33:47 -05:00
|
|
|
test.A
|
2016-09-21 12:55:07 -05:00
|
|
|
test.A (destroy)
|
2016-09-21 13:33:47 -05:00
|
|
|
test.A
|
2016-09-21 15:54:19 -05:00
|
|
|
test.B
|
|
|
|
test.B
|
2016-09-21 12:55:07 -05:00
|
|
|
`
|