mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-24 07:26:26 -06:00
58 lines
1.0 KiB
Go
58 lines
1.0 KiB
Go
|
package terraform
|
||
|
|
||
|
import (
|
||
|
"reflect"
|
||
|
"strings"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestApplyGraphBuilder_impl(t *testing.T) {
|
||
|
var _ GraphBuilder = new(ApplyGraphBuilder)
|
||
|
}
|
||
|
|
||
|
func TestApplyGraphBuilder(t *testing.T) {
|
||
|
diff := &Diff{
|
||
|
Modules: []*ModuleDiff{
|
||
|
&ModuleDiff{
|
||
|
Path: []string{"root"},
|
||
|
Resources: map[string]*InstanceDiff{
|
||
|
// Verify noop doesn't show up in graph
|
||
|
"aws_instance.noop": &InstanceDiff{},
|
||
|
|
||
|
"aws_instance.create": &InstanceDiff{
|
||
|
Attributes: map[string]*ResourceAttrDiff{
|
||
|
"name": &ResourceAttrDiff{
|
||
|
Old: "",
|
||
|
New: "foo",
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
}
|
||
|
|
||
|
b := &ApplyGraphBuilder{
|
||
|
Diff: diff,
|
||
|
}
|
||
|
|
||
|
g, err := b.Build(RootModulePath)
|
||
|
if err != nil {
|
||
|
t.Fatalf("err: %s", err)
|
||
|
}
|
||
|
|
||
|
if !reflect.DeepEqual(g.Path, RootModulePath) {
|
||
|
t.Fatalf("bad: %#v", g.Path)
|
||
|
}
|
||
|
|
||
|
actual := strings.TrimSpace(g.String())
|
||
|
expected := strings.TrimSpace(testApplyGraphBuilderStr)
|
||
|
if actual != expected {
|
||
|
t.Fatalf("bad: %s", actual)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const testApplyGraphBuilderStr = `
|
||
|
aws_instance.create
|
||
|
`
|