Files
kopia/internal/ospath/ospath_test.go
Jarek Kowalski 191a51b278 ui: fixed snapshotting UNC roots (#1401)
This was caused by additional resolution of path names only done in UI,
which caused \\hostname\share to be treated as relative and resolved
against the home directory.

Fixes #1385
Fixes #1362
2021-10-17 13:25:12 -07:00

72 lines
1022 B
Go

package ospath_test
import (
"runtime"
"testing"
"github.com/stretchr/testify/require"
"github.com/kopia/kopia/internal/ospath"
)
func TestIsAbs(t *testing.T) {
var absCases []string
notAbsCases := []string{
"foo",
"foo/",
"foo/bar",
"./foo",
"./foo/bar",
"../foo",
"../foo/",
"../foo/bar",
".",
"..",
"../",
"../..",
}
if runtime.GOOS == "windows" {
absCases = append(absCases,
"c:\\",
"c:\\foo",
"c:\\foo\\",
"c:\\foo\\bar",
"\\\\host\\share",
"\\\\host\\share\\",
"\\\\host\\share\\subdir",
)
notAbsCases = append(notAbsCases,
"..\\",
"..\\..",
"foo",
"foo\\",
"foo\\bar",
".\\foo",
".\\foo\\bar",
"..\\foo",
"..\\foo\\",
"..\\foo\\bar",
"\\\\host",
"\\\\host\\",
)
} else {
absCases = append(absCases,
"/",
"/foo",
"/foo/",
"/foo/bar",
)
}
for _, tc := range absCases {
require.True(t, ospath.IsAbs(tc), tc)
}
for _, tc := range notAbsCases {
require.False(t, ospath.IsAbs(tc), tc)
}
}