lib/fs: Resolve 8.3 filenames from watcher (ref #3800) (#4975)

This commit is contained in:
Simon Frei
2018-06-04 13:41:03 +02:00
committed by GitHub
parent 8b15624f7d
commit ee6516aa31
5 changed files with 136 additions and 35 deletions

View File

@@ -12,12 +12,12 @@ import (
"path/filepath"
"runtime"
"sort"
"strings"
"testing"
"time"
)
func setup(t *testing.T) (Filesystem, string) {
func setup(t *testing.T) (*BasicFilesystem, string) {
t.Helper()
dir, err := ioutil.TempDir("", "")
if err != nil {
t.Fatal(err)
@@ -304,38 +304,6 @@ func TestUsage(t *testing.T) {
}
}
func TestWindowsPaths(t *testing.T) {
if runtime.GOOS != "windows" {
t.Skip("Not useful on non-Windows")
return
}
testCases := []struct {
input string
expectedRoot string
expectedURI string
}{
{`e:\`, `\\?\e:\`, `e:\`},
{`\\?\e:\`, `\\?\e:\`, `e:\`},
{`\\192.0.2.22\network\share`, `\\192.0.2.22\network\share`, `\\192.0.2.22\network\share`},
}
for _, testCase := range testCases {
fs := newBasicFilesystem(testCase.input)
if fs.root != testCase.expectedRoot {
t.Errorf("root %q != %q", fs.root, testCase.expectedRoot)
}
if fs.URI() != testCase.expectedURI {
t.Errorf("uri %q != %q", fs.URI(), testCase.expectedURI)
}
}
fs := newBasicFilesystem(`relative\path`)
if fs.root == `relative\path` || !strings.HasPrefix(fs.root, "\\\\?\\") {
t.Errorf("%q == %q, expected absolutification", fs.root, `relative\path`)
}
}
func TestRooted(t *testing.T) {
type testcase struct {
root string