mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
52 lines
1005 B
Go
52 lines
1005 B
Go
package terraform
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestAddOutputOrphanTransformer(t *testing.T) {
|
|
mod := testModule(t, "transform-orphan-output-basic")
|
|
state := &State{
|
|
Modules: []*ModuleState{
|
|
&ModuleState{
|
|
Path: RootModulePath,
|
|
Outputs: map[string]*OutputState{
|
|
"foo": &OutputState{
|
|
Value: "bar",
|
|
Type: "string",
|
|
},
|
|
"bar": &OutputState{
|
|
Value: "baz",
|
|
Type: "string",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
g := Graph{Path: RootModulePath}
|
|
{
|
|
tf := &ConfigTransformerOld{Module: mod}
|
|
if err := tf.Transform(&g); err != nil {
|
|
t.Fatalf("err: %s", err)
|
|
}
|
|
}
|
|
|
|
transform := &AddOutputOrphanTransformer{State: state}
|
|
if err := transform.Transform(&g); err != nil {
|
|
t.Fatalf("err: %s", err)
|
|
}
|
|
|
|
actual := strings.TrimSpace(g.String())
|
|
expected := strings.TrimSpace(testTransformOrphanOutputBasicStr)
|
|
if actual != expected {
|
|
t.Fatalf("bad:\n\n%s", actual)
|
|
}
|
|
}
|
|
|
|
const testTransformOrphanOutputBasicStr = `
|
|
output.bar (orphan)
|
|
output.foo
|
|
`
|