opentofu/terraform/transform_output_test.go
James Nugent 3ea3c657b5 core: Use OutputState in JSON instead of map
This commit forward ports the changes made for 0.6.17, in order to store
the type and sensitive flag against outputs.

It also refactors the logic of the import for V0 to V1 state, and
fixes up the call sites of the new format for outputs in V2 state.

Finally we fix up tests which did not previously set a state version
where one is required.
2016-05-18 13:25:20 -05:00

52 lines
1002 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 := &ConfigTransformer{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
`