forked from drone-plugins/drone-s3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin_unix_test.go
46 lines (42 loc) · 960 Bytes
/
plugin_unix_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
//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)
}
}
}