opentofu/internal/terraform/transform_vertex_test.go
Kuba Martin ebcf7455eb
Rename root module name. (#4)
* Rename module name from "github.com/hashicorp/terraform" to "github.com/placeholderplaceholderplaceholder/opentf".

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Gofmt.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Regenerate protobuf.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Fix comments.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Undo issue and pull request link changes.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Undo comment changes.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Fix comment.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Undo some link changes.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* make generate && make protobuf

Signed-off-by: Jakub Martin <kubam@spacelift.io>

---------

Signed-off-by: Jakub Martin <kubam@spacelift.io>
2023-08-17 14:45:11 +02:00

62 lines
1.0 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package terraform
import (
"strings"
"testing"
"github.com/placeholderplaceholderplaceholder/opentf/internal/dag"
)
func TestVertexTransformer_impl(t *testing.T) {
var _ GraphTransformer = new(VertexTransformer)
}
func TestVertexTransformer(t *testing.T) {
var g Graph
g.Add(1)
g.Add(2)
g.Add(3)
g.Connect(dag.BasicEdge(1, 2))
g.Connect(dag.BasicEdge(2, 3))
{
tf := &VertexTransformer{
Transforms: []GraphVertexTransformer{
&testVertexTransform{Source: 2, Target: 42},
},
}
if err := tf.Transform(&g); err != nil {
t.Fatalf("err: %s", err)
}
}
actual := strings.TrimSpace(g.String())
expected := strings.TrimSpace(testVertexTransformerStr)
if actual != expected {
t.Fatalf("bad: %s", actual)
}
}
type testVertexTransform struct {
Source, Target dag.Vertex
}
func (t *testVertexTransform) Transform(v dag.Vertex) (dag.Vertex, error) {
if t.Source == v {
v = t.Target
}
return v, nil
}
const testVertexTransformerStr = `
1
42
3
42
3
`