mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-16 11:42:58 -06:00
42 lines
787 B
Go
42 lines
787 B
Go
package terraform
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestDestroyTransformer(t *testing.T) {
|
|
mod := testModule(t, "transform-destroy-basic")
|
|
|
|
g := Graph{Path: RootModulePath}
|
|
{
|
|
tf := &ConfigTransformer{Module: mod}
|
|
if err := tf.Transform(&g); err != nil {
|
|
t.Fatalf("err: %s", err)
|
|
}
|
|
}
|
|
|
|
{
|
|
tf := &DestroyTransformer{}
|
|
if err := tf.Transform(&g); err != nil {
|
|
t.Fatalf("err: %s", err)
|
|
}
|
|
}
|
|
|
|
actual := strings.TrimSpace(g.String())
|
|
expected := strings.TrimSpace(testTransformDestroyBasicStr)
|
|
if actual != expected {
|
|
t.Fatalf("bad:\n\n%s", actual)
|
|
}
|
|
}
|
|
|
|
const testTransformDestroyBasicStr = `
|
|
aws_instance.bar
|
|
aws_instance.bar (destroy)
|
|
aws_instance.bar (destroy)
|
|
aws_instance.foo
|
|
aws_instance.foo
|
|
aws_instance.foo (destroy)
|
|
aws_instance.foo (destroy)
|
|
`
|