-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
new_test.go
50 lines (42 loc) · 1.19 KB
/
new_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
package cache
import (
"testing"
"github.com/ironsmile/nedomi/config"
"github.com/ironsmile/nedomi/mock"
"github.com/ironsmile/nedomi/types"
)
func mockRemove(*types.ObjectIndex) error {
return nil
}
func TestCreatingCacheAlgorithms(t *testing.T) {
t.Parallel()
cz := config.CacheZone{
ID: "default",
Path: "/does/not/matter",
PartSize: 4123123,
StorageObjects: 9813743,
Algorithm: "lru",
}
if _, err := New(&cz, mockRemove, mock.NewLogger()); err != nil {
t.Errorf("Error when creating cache algorithm. %s", err)
}
}
func TestCreatingBogusCacheAlgorithmReturnsError(t *testing.T) {
t.Parallel()
cz := config.CacheZone{
ID: "default",
Path: "/does/not/matter",
PartSize: 4123123,
StorageObjects: 9813743,
Algorithm: "bogus",
}
if _, err := New(&cz, mockRemove, mock.NewLogger()); err == nil {
t.Error("Expected an error when creating bogus algorithm but got none")
}
}
func TestCreatingCacheAlgorithmWithNilConfigReturnsError(t *testing.T) {
t.Parallel()
if _, err := New(nil, mockRemove, mock.NewLogger()); err == nil {
t.Error("Expected an error when creating bogus algorithm but got none")
}
}