diff --git a/drawfence_test.go b/drawfence_test.go index d0e810b..1e30a0d 100644 --- a/drawfence_test.go +++ b/drawfence_test.go @@ -64,10 +64,11 @@ func TestReplayPairsFindsWhatAWholeReplayFinds(t *testing.T) { return nil }) compared := 0 + fold := newReadFold() for _, root := range roots { - compared += wantPairsFindAll(t, root.label, surveyRender(root.t).reads) + compared += wantPairsFindAll(t, root.label, surveyRender(fold, root.t).reads) if root.t.isRecord && len(root.t.fields) > 0 { - compared += wantPairsFindAll(t, root.label+" as a record", surveyColumns(root.t, sortedNames(root.t.fields)).reads) + compared += wantPairsFindAll(t, root.label+" as a record", surveyColumns(fold, root.t, sortedNames(root.t.fields)).reads) } } if compared == 0 { @@ -81,6 +82,7 @@ func TestReplayPairsFindsWhatAWholeReplayOfSelectedRowsFinds(t *testing.T) { t.Fatalf("New = %v", err) } var reads []pathRead + fold := newReadFold() _ = walkNodes(f.root.children, func(_ string, n node) error { tb, isTable := n.(*table) if !isTable || tb.keyIndex < 0 || tb.familyRoot().path != "region" { @@ -95,7 +97,7 @@ func TestReplayPairsFindsWhatAWholeReplayOfSelectedRowsFinds(t *testing.T) { if !isTemplate { t.Fatalf("NewTemplate(%s) compiled to %T", tb.selectorSpelling(r), inline.n) } - reads = append(reads, surveyRender(root).reads...) + reads = append(reads, surveyRender(fold, root).reads...) } return nil }) diff --git a/readsurvey_test.go b/readsurvey_test.go index 184981e..f7a7ee0 100644 --- a/readsurvey_test.go +++ b/readsurvey_test.go @@ -10,8 +10,9 @@ func TestEveryReadARenderMakesIsGathered(t *testing.T) { f := fenceCorpus(t) roots := fenceRoots(t, f) traced := 0 + fold := newReadFold() for _, root := range roots { - traced += wantGathered(t, root.label, surveyRender(root.t).reads, func(trace renderTrace) { renderRoot(f.rand, root.t, trace) }) + traced += wantGathered(t, root.label, surveyRender(fold, root.t).reads, func(trace renderTrace) { renderRoot(f.rand, root.t, trace) }) if !root.t.isRecord || len(root.t.fields) == 0 { continue } @@ -19,7 +20,7 @@ func TestEveryReadARenderMakesIsGathered(t *testing.T) { if err != nil { t.Fatalf("%s: recordOf = %v", root.label, err) } - traced += wantGathered(t, root.label+" as a record", surveyColumns(root.t, sortedNames(root.t.fields)).reads, func(trace renderTrace) { renderRecordRoot(f.rand, root.t, columns, trace) }) + traced += wantGathered(t, root.label+" as a record", surveyColumns(fold, root.t, sortedNames(root.t.fields)).reads, func(trace renderTrace) { renderRecordRoot(f.rand, root.t, columns, trace) }) } if traced == 0 { t.Error("no render traced a reference read, so the comparison proved nothing") @@ -125,7 +126,7 @@ func TestReadSurveyWalksACellByEveryRoute(t *testing.T) { t.Fatalf("r is a %T, want a template", g.children["r"]) } var pinned, whole bool - for _, read := range surveyRender(r).reads { + for _, read := range surveyRender(newReadFold(), r).reads { if read.a.path != "/z" { continue } @@ -157,24 +158,22 @@ func TestReadSurveyReportsAPinClashAsAnError(t *testing.T) { if !isTemplate { t.Fatalf("r is a %T, want a template", g.children["r"]) } - if err := surveyRender(r).check(); err == nil || !strings.Contains(err.Error(), "two rows of") { + if err := surveyRender(newReadFold(), r).check(); err == nil || !strings.Contains(err.Error(), "two rows of") { t.Errorf("check = %v, want y[a]'s row of x clashing with x[2] named, whatever order the fences run in", err) } n, isTemplate := g.children["n"].(*template) if !isTemplate { t.Fatalf("n is a %T, want a template", g.children["n"]) } - if err := surveyRender(n).check(); err == nil || !strings.HasPrefix(err.Error(), "{f} with {/x[2].v}: x[1] and x[2] are two rows of x") { + if err := surveyRender(newReadFold(), n).check(); err == nil || !strings.HasPrefix(err.Error(), "{f} with {/x[2].v}: x[1] and x[2] are two rows of x") { t.Errorf("check = %v, want the clash below {f} named by the route the root reaches it by", err) } } -func surveyRender(t *template) *readSurvey { - f := newReadFold() +func surveyRender(f *readFold, t *template) *readSurvey { return survey(f.rootReads(t), t.link.drawGroupKey) } -func surveyColumns(t *template, columns []string) *readSurvey { - f := newReadFold() +func surveyColumns(f *readFold, t *template, columns []string) *readSurvey { return survey(f.columnReads(t, columns), t.link.drawGroupKey) }