-
Notifications
You must be signed in to change notification settings - Fork 0
/
paths_test.go
48 lines (43 loc) · 1.03 KB
/
paths_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
package filecache_test
import (
"testing"
"github.com/kukymbr/filecache/v2"
"github.com/stretchr/testify/assert"
)
func TestPathGenerators(t *testing.T) {
tests := []struct {
Key string
Fn filecache.PathGeneratorFn
Expected string
}{
{
Key: "test1/test",
Fn: filecache.FilteredKeyPath,
Expected: "test1test",
},
{
Key: "test2",
Fn: filecache.WithExt(filecache.FilteredKeyPath, " .cache "),
Expected: "test2.cache",
},
{
Key: "test3",
Fn: filecache.WithExt(filecache.HashedKeyPath, ".json"),
Expected: "3ebfa301dc59196f18593c45e519287a23297589.json",
},
{
Key: "test4",
Fn: filecache.WithExt(filecache.HashedKeySplitPath, "html"),
Expected: "1f/f2/b3/704aede04eecb51e50ca698efd50a1379b.html",
},
{
Key: "///",
Fn: filecache.FilteredKeyPath,
Expected: "c64b8480a468e7f8b15abd0cb49a4f9a451af542",
},
}
for i, test := range tests {
path := test.Fn(test.Key)
assert.Equal(t, test.Expected, path, i)
}
}