Return helpful error if subfolder syntax fails on Windows (#21813)

This commit is contained in:
Michael Eischer
2026-05-20 22:55:01 +02:00
committed by GitHub
parent dd4f1f06a1
commit f000da3b35
9 changed files with 33 additions and 11 deletions
+17
View File
@@ -7,6 +7,7 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"slices"
"strconv"
"strings"
@@ -401,6 +402,22 @@ func TestFindTreeDirectory(t *testing.T) {
rtest.Assert(t, err != nil, "missing error on null tree id")
}
func TestFindTreeDirectoryWindowsBackslashHint(t *testing.T) {
repo := repository.TestRepository(t)
sn := data.TestCreateSnapshot(t, repo, parseTimeUTC("2017-07-07 07:07:08"), 1)
_, err := data.FindTreeDirectory(context.TODO(), repo, sn.Tree, `missing\path`)
rtest.Assert(t, err != nil, "expected error")
if runtime.GOOS == "windows" {
rtest.Assert(t, strings.Contains(err.Error(), "forward slashes"),
"expected backslash hint on Windows, got %v", err)
} else {
rtest.Assert(t, err.Error() == `path missing\path: not found`,
"unexpected err: %v", err)
}
}
func TestDualTreeIterator(t *testing.T) {
testErr := errors.New("test error")