terraform: tests for ReferenceMap for module paths
This commit is contained in:
parent
576b61a21d
commit
22dd4303bc
|
@ -138,6 +138,54 @@ func TestReferenceTransformer_backupPrimary(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestReferenceTransformer_modulePath(t *testing.T) {
|
||||||
|
g := Graph{Path: RootModulePath}
|
||||||
|
g.Add(&graphNodeRefParentTest{
|
||||||
|
NameValue: "A",
|
||||||
|
Names: []string{"A"},
|
||||||
|
PathValue: []string{"foo"},
|
||||||
|
})
|
||||||
|
g.Add(&graphNodeRefChildTest{
|
||||||
|
NameValue: "B",
|
||||||
|
Refs: []string{"module.foo"},
|
||||||
|
})
|
||||||
|
|
||||||
|
tf := &ReferenceTransformer{}
|
||||||
|
if err := tf.Transform(&g); err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
actual := strings.TrimSpace(g.String())
|
||||||
|
expected := strings.TrimSpace(testTransformRefModulePathStr)
|
||||||
|
if actual != expected {
|
||||||
|
t.Fatalf("bad:\n\n%s", actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReferenceTransformer_modulePathNormalized(t *testing.T) {
|
||||||
|
g := Graph{Path: RootModulePath}
|
||||||
|
g.Add(&graphNodeRefParentTest{
|
||||||
|
NameValue: "A",
|
||||||
|
Names: []string{"A"},
|
||||||
|
PathValue: []string{"root", "foo"},
|
||||||
|
})
|
||||||
|
g.Add(&graphNodeRefChildTest{
|
||||||
|
NameValue: "B",
|
||||||
|
Refs: []string{"module.foo"},
|
||||||
|
})
|
||||||
|
|
||||||
|
tf := &ReferenceTransformer{}
|
||||||
|
if err := tf.Transform(&g); err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
actual := strings.TrimSpace(g.String())
|
||||||
|
expected := strings.TrimSpace(testTransformRefModulePathStr)
|
||||||
|
if actual != expected {
|
||||||
|
t.Fatalf("bad:\n\n%s", actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestReferenceMapReferences(t *testing.T) {
|
func TestReferenceMapReferences(t *testing.T) {
|
||||||
cases := map[string]struct {
|
cases := map[string]struct {
|
||||||
Nodes []dag.Vertex
|
Nodes []dag.Vertex
|
||||||
|
@ -265,6 +313,12 @@ B
|
||||||
C
|
C
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const testTransformRefModulePathStr = `
|
||||||
|
A
|
||||||
|
B
|
||||||
|
A
|
||||||
|
`
|
||||||
|
|
||||||
const testTransformRefPathStr = `
|
const testTransformRefPathStr = `
|
||||||
A
|
A
|
||||||
B
|
B
|
||||||
|
|
Loading…
Reference in New Issue