update some graph builder tests
Reduce the graphs, as they are too ungainly to compare without reduction. We also depend on reduction in all use cases, so we should be testing the graph as we use it anyway.
This commit is contained in:
parent
1f374dc446
commit
f1657bb3e3
|
@ -45,11 +45,10 @@ func TestApplyGraphBuilder(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
b := &ApplyGraphBuilder{
|
b := &ApplyGraphBuilder{
|
||||||
Config: testModule(t, "graph-builder-apply-basic"),
|
Config: testModule(t, "graph-builder-apply-basic"),
|
||||||
Changes: changes,
|
Changes: changes,
|
||||||
Components: simpleMockComponentFactory(),
|
Components: simpleMockComponentFactory(),
|
||||||
Schemas: simpleTestSchemas(),
|
Schemas: simpleTestSchemas(),
|
||||||
DisableReduce: true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g, err := b.Build(addrs.RootModuleInstance)
|
g, err := b.Build(addrs.RootModuleInstance)
|
||||||
|
@ -62,6 +61,7 @@ func TestApplyGraphBuilder(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
actual := strings.TrimSpace(g.String())
|
actual := strings.TrimSpace(g.String())
|
||||||
|
|
||||||
expected := strings.TrimSpace(testApplyGraphBuilderStr)
|
expected := strings.TrimSpace(testApplyGraphBuilderStr)
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Fatalf("wrong result\n\ngot:\n%s\n\nwant:\n%s", actual, expected)
|
t.Fatalf("wrong result\n\ngot:\n%s\n\nwant:\n%s", actual, expected)
|
||||||
|
@ -89,18 +89,16 @@ func TestApplyGraphBuilder_depCbd(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
b := &ApplyGraphBuilder{
|
b := &ApplyGraphBuilder{
|
||||||
Config: testModule(t, "graph-builder-apply-dep-cbd"),
|
Config: testModule(t, "graph-builder-apply-dep-cbd"),
|
||||||
Changes: changes,
|
Changes: changes,
|
||||||
Components: simpleMockComponentFactory(),
|
Components: simpleMockComponentFactory(),
|
||||||
Schemas: simpleTestSchemas(),
|
Schemas: simpleTestSchemas(),
|
||||||
DisableReduce: true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g, err := b.Build(addrs.RootModuleInstance)
|
g, err := b.Build(addrs.RootModuleInstance)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
t.Logf("Graph: %s", g.String())
|
|
||||||
|
|
||||||
if g.Path.String() != addrs.RootModuleInstance.String() {
|
if g.Path.String() != addrs.RootModuleInstance.String() {
|
||||||
t.Fatalf("wrong path %q", g.Path.String())
|
t.Fatalf("wrong path %q", g.Path.String())
|
||||||
|
@ -123,10 +121,9 @@ func TestApplyGraphBuilder_depCbd(t *testing.T) {
|
||||||
t.Fatalf("no deposed instance node in the graph; want one")
|
t.Fatalf("no deposed instance node in the graph; want one")
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyName := fmt.Sprintf("test_object.A (deposed %s)", dk)
|
destroyName := fmt.Sprintf("test_object.A (destroy deposed %s)", dk)
|
||||||
|
|
||||||
// Create A, Modify B, Destroy A
|
// Create A, Modify B, Destroy A
|
||||||
|
|
||||||
testGraphHappensBefore(
|
testGraphHappensBefore(
|
||||||
t, g,
|
t, g,
|
||||||
"test_object.A",
|
"test_object.A",
|
||||||
|
@ -444,25 +441,22 @@ func TestApplyGraphBuilder_targetModule(t *testing.T) {
|
||||||
|
|
||||||
const testApplyGraphBuilderStr = `
|
const testApplyGraphBuilderStr = `
|
||||||
meta.count-boundary (EachMode fixup)
|
meta.count-boundary (EachMode fixup)
|
||||||
module.child.provisioner.test
|
|
||||||
module.child.test_object.create
|
|
||||||
module.child.test_object.other
|
module.child.test_object.other
|
||||||
provider.test
|
|
||||||
test_object.create
|
|
||||||
test_object.other
|
test_object.other
|
||||||
module.child.provisioner.test
|
module.child.provisioner.test
|
||||||
module.child.test_object.create
|
module.child.test_object.create
|
||||||
|
module.child.test_object.create (prepare state)
|
||||||
|
module.child.test_object.create (prepare state)
|
||||||
module.child.provisioner.test
|
module.child.provisioner.test
|
||||||
provider.test
|
provider.test
|
||||||
module.child.test_object.other
|
module.child.test_object.other
|
||||||
module.child.test_object.create
|
module.child.test_object.create
|
||||||
|
module.child.test_object.other (prepare state)
|
||||||
|
module.child.test_object.other (prepare state)
|
||||||
provider.test
|
provider.test
|
||||||
provider.test
|
provider.test
|
||||||
provider.test (close)
|
provider.test (close)
|
||||||
module.child.test_object.create
|
|
||||||
module.child.test_object.other
|
module.child.test_object.other
|
||||||
provider.test
|
|
||||||
test_object.create
|
|
||||||
test_object.other
|
test_object.other
|
||||||
provisioner.test (close)
|
provisioner.test (close)
|
||||||
module.child.test_object.create
|
module.child.test_object.create
|
||||||
|
@ -471,10 +465,14 @@ root
|
||||||
provider.test (close)
|
provider.test (close)
|
||||||
provisioner.test (close)
|
provisioner.test (close)
|
||||||
test_object.create
|
test_object.create
|
||||||
|
test_object.create (prepare state)
|
||||||
|
test_object.create (prepare state)
|
||||||
provider.test
|
provider.test
|
||||||
test_object.other
|
test_object.other
|
||||||
provider.test
|
|
||||||
test_object.create
|
test_object.create
|
||||||
|
test_object.other (prepare state)
|
||||||
|
test_object.other (prepare state)
|
||||||
|
provider.test
|
||||||
`
|
`
|
||||||
|
|
||||||
const testApplyGraphBuilderDoubleCBDStr = `
|
const testApplyGraphBuilderDoubleCBDStr = `
|
||||||
|
|
|
@ -35,6 +35,7 @@ func testGraphNotContains(t *testing.T, g *Graph, name string) {
|
||||||
// testGraphHappensBefore is an assertion helper that tests that node
|
// testGraphHappensBefore is an assertion helper that tests that node
|
||||||
// A (dag.VertexName value) happens before node B.
|
// A (dag.VertexName value) happens before node B.
|
||||||
func testGraphHappensBefore(t *testing.T, g *Graph, A, B string) {
|
func testGraphHappensBefore(t *testing.T, g *Graph, A, B string) {
|
||||||
|
t.Helper()
|
||||||
// Find the B vertex
|
// Find the B vertex
|
||||||
var vertexB dag.Vertex
|
var vertexB dag.Vertex
|
||||||
for _, v := range g.Vertices() {
|
for _, v := range g.Vertices() {
|
||||||
|
|
Loading…
Reference in New Issue