test(list): pin --deps scheduling ordering under --sort closed in the tree
Render the tree with depsMode=scheduling and sortBy=closed at both the root level and under one parent: the blocks edge must still put dep before late, while the requested sort (not priority) puts the unlinked free first. Covers both orderSiblingsByDeps call sites in list_tree.go. AC: AC-3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d29c4611e6
commit
f434dcd5e4
1 changed files with 44 additions and 0 deletions
|
|
@ -327,6 +327,50 @@ func TestListDisplayPrettyListHonorsSort(t *testing.T) {
|
|||
t.Fatalf("tree siblings ignore --sort closed:\n%s", out)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("deps scheduling", func(t *testing.T) {
|
||||
// At both levels the --deps tree orders (roots, and one parent's
|
||||
// children): late depends on dep, so dep prints first although --sort
|
||||
// closed alone would lead with the newer late; free has no edge, so
|
||||
// --sort closed puts it ahead of dep, where priority would put it last.
|
||||
oldest := time.Now().Add(-3 * time.Hour)
|
||||
parentAt := time.Now().Add(-4 * time.Hour)
|
||||
parent := &types.Issue{ID: "bd-parent", Title: "Parent", Status: types.StatusClosed, Priority: 2, IssueType: types.TypeEpic, ClosedAt: &parentAt}
|
||||
rootDep := &types.Issue{ID: "bd-root-dep", Title: "Root dependency", Status: types.StatusClosed, Priority: 0, IssueType: types.TypeTask, ClosedAt: &oldest}
|
||||
rootLate := &types.Issue{ID: "bd-root-late", Title: "Root dependent", Status: types.StatusClosed, Priority: 1, IssueType: types.TypeTask, ClosedAt: &newer}
|
||||
rootFree := &types.Issue{ID: "bd-root-free", Title: "Root unlinked", Status: types.StatusClosed, Priority: 2, IssueType: types.TypeTask, ClosedAt: &older}
|
||||
childDep := &types.Issue{ID: "bd-child-dep", Title: "Child dependency", Status: types.StatusClosed, Priority: 0, IssueType: types.TypeTask, ClosedAt: &oldest}
|
||||
childLate := &types.Issue{ID: "bd-child-late", Title: "Child dependent", Status: types.StatusClosed, Priority: 1, IssueType: types.TypeTask, ClosedAt: &newer}
|
||||
childFree := &types.Issue{ID: "bd-child-free", Title: "Child unlinked", Status: types.StatusClosed, Priority: 2, IssueType: types.TypeTask, ClosedAt: &older}
|
||||
deps := map[string][]*types.Dependency{
|
||||
rootLate.ID: {{IssueID: rootLate.ID, DependsOnID: rootDep.ID, Type: types.DepBlocks}},
|
||||
childDep.ID: {{IssueID: childDep.ID, DependsOnID: parent.ID, Type: types.DepParentChild}},
|
||||
childFree.ID: {{IssueID: childFree.ID, DependsOnID: parent.ID, Type: types.DepParentChild}},
|
||||
childLate.ID: {
|
||||
{IssueID: childLate.ID, DependsOnID: parent.ID, Type: types.DepParentChild},
|
||||
{IssueID: childLate.ID, DependsOnID: childDep.ID, Type: types.DepBlocks},
|
||||
},
|
||||
}
|
||||
issues := []*types.Issue{parent, rootDep, rootLate, rootFree, childDep, childLate, childFree}
|
||||
|
||||
out := captureStdout(t, func() error {
|
||||
displayPrettyListWithDepsMode(issues, false, deps, "scheduling", false, false, "closed", "closed", false, nil)
|
||||
return nil
|
||||
})
|
||||
// A dependency's id also appears on its dependent's annotation row; the
|
||||
// first occurrence is still the dependency's own row whenever it prints first.
|
||||
for _, want := range [][]string{
|
||||
{rootFree.ID, rootDep.ID, rootLate.ID},
|
||||
{childFree.ID, childDep.ID, childLate.ID},
|
||||
} {
|
||||
for i := 1; i < len(want); i++ {
|
||||
before, after := strings.Index(out, want[i-1]), strings.Index(out, want[i])
|
||||
if before < 0 || after < 0 || before > after {
|
||||
t.Fatalf("--deps scheduling --sort closed: want %s before %s:\n%s", want[i-1], want[i], out)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestListDisplayPrettyList(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue