-
Notifications
You must be signed in to change notification settings - Fork 14
/
derive_test.go
106 lines (97 loc) · 2.77 KB
/
derive_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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package subkey
import (
"testing"
"github.com/stretchr/testify/assert"
)
//nolint:funlen
func TestSplitURI(t *testing.T) {
tests := []struct {
suri, phrase, path, password string
err bool
}{
{
suri: "bottom drive obey lake curtain smoke basket hold race lonely fit walk///password",
phrase: "bottom drive obey lake curtain smoke basket hold race lonely fit walk",
path: "",
password: "password",
},
{
suri: "bottom drive obey lake curtain smoke basket hold race lonely fit walk",
phrase: "bottom drive obey lake curtain smoke basket hold race lonely fit walk",
path: "",
password: "",
},
{
suri: "bottom drive obey lake curtain smoke basket hold race lonely fit walk/foo",
phrase: "bottom drive obey lake curtain smoke basket hold race lonely fit walk",
path: "/foo",
password: "",
},
{
suri: "bottom drive obey lake curtain smoke basket hold race lonely fit walk//foo",
phrase: "bottom drive obey lake curtain smoke basket hold race lonely fit walk",
path: "//foo",
password: "",
},
{
suri: "bottom drive obey lake curtain smoke basket hold race lonely fit walk//foo/bar",
phrase: "bottom drive obey lake curtain smoke basket hold race lonely fit walk",
path: "//foo/bar",
password: "",
},
{
suri: "bottom drive obey lake curtain smoke basket hold race lonely fit walk/foo//bar",
phrase: "bottom drive obey lake curtain smoke basket hold race lonely fit walk",
path: "/foo//bar",
password: "",
},
{
suri: "bottom drive obey lake curtain smoke basket hold race lonely fit walk//foo/bar//42/69",
phrase: "bottom drive obey lake curtain smoke basket hold race lonely fit walk",
path: "//foo/bar//42/69",
password: "",
},
{
suri: "bottom drive obey lake curtain smoke basket hold race lonely fit walk//foo/bar//42/69///password",
phrase: "bottom drive obey lake curtain smoke basket hold race lonely fit walk",
path: "//foo/bar//42/69",
password: "password",
},
{
suri: "/Alice",
phrase: DevPhrase,
path: "/Alice",
password: "",
},
{
suri: "/Alice///password",
phrase: DevPhrase,
path: "/Alice",
password: "password",
},
{
suri: "//Alice///password",
phrase: DevPhrase,
path: "//Alice",
password: "password",
},
{
suri: "//Alice",
phrase: DevPhrase,
path: "//Alice",
password: "",
},
}
for _, c := range tests {
t.Run(c.suri, func(t *testing.T) {
phrase, path, password, err := splitURI(c.suri)
if err != nil {
assert.True(t, c.err)
return
}
assert.Equal(t, c.phrase, phrase)
assert.Equal(t, c.path, path)
assert.Equal(t, c.password, password)
})
}
}