Progress reads only a design's head, and says so beside the tracker's tree when even that fails (issue 1947)
This commit is contained in:
@@ -142,6 +142,19 @@ func (c *countingRecords) Read(p string) (string, string, error) {
|
||||
return content, c.commit, err
|
||||
}
|
||||
|
||||
func (c *countingRecords) ReadHead(p string, n int) (string, string, error) {
|
||||
c.reads++
|
||||
content, _, err := c.dirRecords.ReadHead(p, n)
|
||||
return content, c.commit, err
|
||||
}
|
||||
|
||||
// brokenRead is Records whose reads fail as the records module's do for a document longer than it answers whole.
|
||||
type brokenRead struct{ dirRecords }
|
||||
|
||||
func (brokenRead) ReadHead(p string, n int) (string, string, error) {
|
||||
return "", "", fmt.Errorf("%s is longer than the records module answers whole", p)
|
||||
}
|
||||
|
||||
// 1947/AC2, as issue 1781 changed it: a design's title, state and decisions are hq's; its milestones are the issue
|
||||
// tracker's records, ordered as its table, an id found with spaces or hyphens, and a closed one holding no issue done.
|
||||
func TestADesignsMilestonesAreTheTrackersRecords(t *testing.T) {
|
||||
@@ -316,6 +329,12 @@ func TestProgressOfADesignMinimalAndDetailed(t *testing.T) {
|
||||
if big, _ := k.Progress(ProgressAsk{Of: "design 47", Bound: 8192}); big.Cut != "" || big.Tree != p.Tree {
|
||||
t.Errorf("a minimal answer at bound 8192 is cut: %q", big.Cut)
|
||||
}
|
||||
// A design whose head the records module cannot read is said in a warning beside the tracker-built tree, never a failure.
|
||||
kb := &KB{Records: brokenRead{progressRecords()}, Seats: newSeatsWorld(t).ask, Now: k.Now}
|
||||
if bp, err := kb.Progress(ProgressAsk{Of: "design 47"}); err != nil || !strings.Contains(strings.Join(bp.Warnings, "\n"), "does not read") ||
|
||||
!strings.Contains(bp.Tree, "design 47") || !strings.Contains(bp.Tree, "R6") {
|
||||
t.Fatalf("an unreadable design: %v %+v", err, bp)
|
||||
}
|
||||
lines := strings.Split(p.Tree, "\n")
|
||||
if !strings.HasPrefix(lines[0], "✗ design 47 · Delivery: from a commit to delivered — ") {
|
||||
t.Fatalf("first line %q", lines[0])
|
||||
|
||||
Reference in New Issue
Block a user