storj/internal/fpath/path_windows_test.go
Stefan Benten 586ed1b58d
Improve path handling + filepath handling framework (#423)
* Initial Layout

* Commit to test File Handling OS independed

* Hide struct properties to prevent manual interaction

* Fix Linting Errors

* 1st Working Windows Version

* Add missing Error Handling

* Fix Linting Errors

* Remove dependencies

* Further Improvements

* Remove commented code

* Improve comments and error messages

* No pointers to FPath

* Improve comment

* Do not filepath.ToSlash URL path

* Extract helper functions for parsing local path and Storj path

* Minor Improvements based on PR Comments

* Fix Linting Error and make Regex private

* Improve Layout

* Rework FPath and add tests

* Add more tests cases for windows

* Use for-loop instead of goto

* Use FPath in all uplink commands

* Add guard checks

* Add Test Cases and add comments
2018-10-15 16:10:20 +02:00

107 lines
1.3 KiB
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package fpath
import (
"testing"
)
func TestLocalPathWindows(t *testing.T) {
for i, tt := range []struct {
url string
base string
}{
{
url: `\`,
base: `\`,
},
{
url: `\\`,
base: `\`,
},
{
url: `c:\`,
base: `\`,
},
{
url: `c:\`,
base: `\`,
},
{
url: `c:\a\b\c`,
base: `c`,
},
{
url: `c:\\a\\b\\c`,
base: `c`,
},
{
url: `c:/a/b/c`,
base: `c`,
},
{
url: `c://a//b//c`,
base: `c`,
},
{
url: `c:\a/b\c`,
base: `c`,
},
{
url: `\\a/b\c`,
base: `c`,
},
{
url: `a\b\c`,
base: `c`,
},
{
url: `a/b/c`,
base: `c`,
},
{
url: `\\\a\b\c`,
base: `c`,
},
{
url: `///a/b/c`,
base: `c`,
},
{
url: `\\\unc\a\b\c`,
base: `c`,
},
{
url: `///unc/a/b/c`,
base: `c`,
},
{
url: `\\?\UNC\a\b\c`,
base: `c`,
},
{
url: `\\?\C:\a\b\c`,
base: `c`,
},
{
url: `\\?\C:\\a\\b\\c`,
base: `c`,
},
{
url: `C:\a\b\`,
base: `b`,
},
{
url: `C:\a\b\c.txt:extended`,
base: `c.txt:extended`,
},
{
url: `\\a\b\c.txt:extended`,
base: `c.txt:extended`,
},
} {
testLocalPath(t, tt.url, tt.base, i)
}
}