-
Notifications
You must be signed in to change notification settings - Fork 11
/
empty_test.go
56 lines (44 loc) · 1.03 KB
/
empty_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
package cache
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/suite"
)
const (
mockEmptyPfx = "empty-pfx"
mockEmptyKey = "empty-key"
)
var (
mockEmptyCTX = context.Background()
)
type emptySuite struct {
suite.Suite
}
func (s *emptySuite) SetupSuite() {
}
func (s *emptySuite) TearDownSuite() {}
func (s *emptySuite) SetupTest() {}
func (s *emptySuite) TearDownTest() {
// prevent registering twice
ClearPrefix()
}
func TestEmptySuite(t *testing.T) {
suite.Run(t, new(emptySuite))
}
func (s *emptySuite) TestEmptyAdapter() {
f := NewFactory(NewEmpty(), NewEmpty())
c := f.NewCache([]Setting{
{
Prefix: mockEmptyPfx,
CacheAttributes: map[Type]Attribute{
SharedCacheType: {time.Hour},
LocalCacheType: {10 * time.Second},
},
},
})
var intf interface{}
s.Require().Equal(ErrCacheMiss, c.Get(mockEmptyCTX, mockEmptyPfx, mockEmptyKey, &intf))
s.Require().NoError(c.Set(mockEmptyCTX, mockEmptyPfx, mockEmptyKey, 123))
s.Require().NoError(c.Del(mockEmptyCTX, mockEmptyPfx, mockEmptyKey))
}