mirror of
https://github.com/restic/restic.git
synced 2026-08-25 15:03:17 +00:00
Return helpful error if subfolder syntax fails on Windows (#21813)
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user