forked from drone-plugins/drone-s3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin_windows_test.go
60 lines (56 loc) · 1.18 KB
/
plugin_windows_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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)
}
}
}