make sure CBD test graphs are valid

The graphs used for the CBD tests wouldn't validate because they skipped
adding the root module node. Re add the root module transformer and
transitive reduction transformer to the build steps, and match the new
reduced output in the test fixtures.
This commit is contained in:
James Bardin 2022-03-11 09:33:33 -05:00
parent 0bc69d64ec
commit b1de94a176
1 changed files with 6 additions and 7 deletions

View File

@ -46,7 +46,12 @@ func cbdTestSteps(steps []GraphTransformer) []GraphTransformer {
panic("CBDEdgeTransformer not found") panic("CBDEdgeTransformer not found")
} }
return steps[:i+1] // re-add the root node so we have a valid graph for a walk, then reduce
// the graph for less output
steps = append(steps[:i+1], &CloseRootModuleTransformer{})
steps = append(steps, &TransitiveReductionTransformer{})
return steps
} }
// remove extra nodes for easier test comparisons // remove extra nodes for easier test comparisons
@ -105,7 +110,6 @@ func TestCBDEdgeTransformer(t *testing.T) {
expected := regexp.MustCompile(strings.TrimSpace(` expected := regexp.MustCompile(strings.TrimSpace(`
(?m)test_object.A (?m)test_object.A
test_object.A \(destroy deposed \w+\) test_object.A \(destroy deposed \w+\)
test_object.A
test_object.B test_object.B
test_object.B test_object.B
test_object.A test_object.A
@ -178,11 +182,9 @@ func TestCBDEdgeTransformerMulti(t *testing.T) {
expected := regexp.MustCompile(strings.TrimSpace(` expected := regexp.MustCompile(strings.TrimSpace(`
(?m)test_object.A (?m)test_object.A
test_object.A \(destroy deposed \w+\) test_object.A \(destroy deposed \w+\)
test_object.A
test_object.C test_object.C
test_object.B test_object.B
test_object.B \(destroy deposed \w+\) test_object.B \(destroy deposed \w+\)
test_object.B
test_object.C test_object.C
test_object.C test_object.C
test_object.A test_object.A
@ -253,7 +255,6 @@ func TestCBDEdgeTransformer_depNonCBDCount(t *testing.T) {
expected := regexp.MustCompile(strings.TrimSpace(` expected := regexp.MustCompile(strings.TrimSpace(`
(?m)test_object.A (?m)test_object.A
test_object.A \(destroy deposed \w+\) test_object.A \(destroy deposed \w+\)
test_object.A
test_object.B\[0\] test_object.B\[0\]
test_object.B\[1\] test_object.B\[1\]
test_object.B\[0\] test_object.B\[0\]
@ -339,12 +340,10 @@ func TestCBDEdgeTransformer_depNonCBDCountBoth(t *testing.T) {
expected := regexp.MustCompile(strings.TrimSpace(` expected := regexp.MustCompile(strings.TrimSpace(`
test_object.A\[0\] test_object.A\[0\]
test_object.A\[0\] \(destroy deposed \w+\) test_object.A\[0\] \(destroy deposed \w+\)
test_object.A\[0\]
test_object.B\[0\] test_object.B\[0\]
test_object.B\[1\] test_object.B\[1\]
test_object.A\[1\] test_object.A\[1\]
test_object.A\[1\] \(destroy deposed \w+\) test_object.A\[1\] \(destroy deposed \w+\)
test_object.A\[1\]
test_object.B\[0\] test_object.B\[0\]
test_object.B\[1\] test_object.B\[1\]
test_object.B\[0\] test_object.B\[0\]