Skip to content

Commit

Permalink
order children in test
Browse files Browse the repository at this point in the history
  • Loading branch information
LandonTClipp committed Dec 19, 2023
1 parent 71657b4 commit 473a99e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion walk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,12 @@ func TestErrWalkSkipSubtree(t *testing.T) {

for _, tt := range []test{
{
// In AlgorithmBasic, the ordering in which children/nodes are visited
// is filesystem and OS dependent. Some filesystems return paths in a lexically-ordered
// manner, some return them in the order in which they were created. For this test,
// we tell the walker to order the children before iterating over them. That way,
// the test will visit "subdir1/subdir2/foo.txt" before "subdir1/subdir2/subdir3/foo.txt",
// in which case we would tell the walker to skip the subdir3 subtree before it recursed.
"Basic",
AlgorithmBasic,
nil,
Expand Down Expand Up @@ -456,7 +462,7 @@ func TestErrWalkSkipSubtree(t *testing.T) {
} {
t.Run(tt.name, func(t *testing.T) {
root := NewPath(t.TempDir())
walker, err := NewWalk(root, WalkAlgorithm(tt.algorithm), WalkVisitDirs(false))
walker, err := NewWalk(root, WalkAlgorithm(tt.algorithm), WalkVisitDirs(false), WalkSortChildren(true))
require.NoError(t, err)

var tree []*Path
Expand Down

0 comments on commit 473a99e

Please sign in to comment.