-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle upload path correctly for windows (#88)
- Loading branch information
1 parent
338f926
commit 6a80ffa
Showing
4 changed files
with
155 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris | ||
|
||
package main | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestResolveUnixKey(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
target string | ||
srcPath string | ||
stripPrefix string | ||
expected string | ||
}{ | ||
{ | ||
name: "target not set", | ||
target: "", | ||
srcPath: "/foo/bar", | ||
stripPrefix: "/foo", | ||
expected: "/bar", | ||
}, | ||
{ | ||
name: "strip prefix not set", | ||
target: "/hello", | ||
srcPath: "/foo/bar", | ||
stripPrefix: "", | ||
expected: "/hello/foo/bar", | ||
}, | ||
{ | ||
name: "everything set", | ||
target: "hello", | ||
srcPath: "/foo/bar", | ||
stripPrefix: "/foo", | ||
expected: "/hello/bar", | ||
}, | ||
} | ||
|
||
for _, tc := range tests { | ||
got := resolveKey(tc.target, tc.srcPath, tc.stripPrefix) | ||
if tc.expected != got { | ||
t.Fatalf("%s: expected error: %v, got: %v", tc.name, tc.expected, got) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//go:build windows | ||
|
||
package main | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestResolveWinKey(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
target string | ||
srcPath string | ||
stripPrefix string | ||
expected string | ||
}{ | ||
{ | ||
name: "target not set", | ||
target: "", | ||
srcPath: "/foo/bar", | ||
stripPrefix: "/foo", | ||
expected: "/bar", | ||
}, | ||
{ | ||
name: "strip prefix not set", | ||
target: "/hello", | ||
srcPath: "/foo/bar", | ||
stripPrefix: "", | ||
expected: "/hello/foo/bar", | ||
}, | ||
{ | ||
name: "everything set", | ||
target: "hello", | ||
srcPath: "/foo/bar", | ||
stripPrefix: "/foo", | ||
expected: "/hello/bar", | ||
}, | ||
{ | ||
name: "backslash strip prefix", | ||
target: "hello", | ||
srcPath: `foo/bar/world`, | ||
stripPrefix: `foo\bar`, | ||
expected: "/hello/world", | ||
}, | ||
{ | ||
name: "forward slash strip prefix", | ||
target: "hello", | ||
srcPath: "foo/bar/world", | ||
stripPrefix: `foo/bar`, | ||
expected: "/hello/world", | ||
}, | ||
} | ||
|
||
for _, tc := range tests { | ||
got := resolveKey(tc.target, tc.srcPath, tc.stripPrefix) | ||
if tc.expected != got { | ||
t.Fatalf("%s: expected error: %v, got: %v", tc.name, tc.expected, got) | ||
} | ||
} | ||
} |