-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmount_test.go
80 lines (77 loc) · 1.45 KB
/
mount_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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package hackpadfs
import (
"errors"
"fmt"
"testing"
"github.com/hack-pad/hackpadfs/internal/assert"
)
func TestStripErrPathPrefix(t *testing.T) {
t.Parallel()
someError := errors.New("some error")
for _, tc := range []struct {
err error
name string
mountSubPath string
expectErr error
}{
{
err: nil,
expectErr: nil,
},
{
err: someError,
expectErr: someError,
},
{
err: &PathError{
Op: "foo",
Path: "biff/baz/bar",
Err: someError,
},
name: "baz/bar",
mountSubPath: "biff/baz/bar",
expectErr: &PathError{
Op: "foo",
Path: "baz/bar",
Err: someError,
},
},
{
err: &PathError{
Op: "foo",
Path: "biff/baz/bar",
Err: someError,
},
name: "biff/baz/bar",
mountSubPath: "biff/baz/bar",
expectErr: &PathError{
Op: "foo",
Path: "biff/baz/bar",
Err: someError,
},
},
{
err: &LinkError{
Op: "foo",
Old: "biff/baz/bar",
New: "biff/baz/bat",
Err: someError,
},
name: "baz/bar",
mountSubPath: "biff/baz/bar",
expectErr: &LinkError{
Op: "foo",
Old: "baz/bar",
New: "baz/bat",
Err: someError,
},
},
} {
tc := tc // enable parallel sub-tests
t.Run(fmt.Sprint(tc.err, tc.name, tc.mountSubPath), func(t *testing.T) {
t.Parallel()
err := stripErrPathPrefix(tc.err, tc.name, tc.mountSubPath)
assert.Equal(t, tc.expectErr, err)
})
}
}