-
Notifications
You must be signed in to change notification settings - Fork 2
/
redis_test.go
86 lines (70 loc) · 1.65 KB
/
redis_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
package cachita
import (
"os"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestNewRedisCache(t *testing.T) {
t.Parallel()
newCache(rc(t), t)
}
func TestRedisCacheExpires(t *testing.T) {
t.Parallel()
cacheExpires(rc(t), t, time.Second, 1200*time.Millisecond)
}
func TestRedisCacheWithInt(t *testing.T) {
t.Parallel()
cacheWithInt(rc(t), t)
}
func BenchmarkRedisCacheWithInt(b *testing.B) {
benchmarkCacheWithInt(rc(b), b)
}
func TestRedisCacheWithString(t *testing.T) {
t.Parallel()
cacheWithString(rc(t), t)
}
func BenchmarkRedisCacheWithString(b *testing.B) {
benchmarkCacheWithString(rc(b), b)
}
func TestRedisCacheWithMapInterface(t *testing.T) {
t.Parallel()
cacheWithMapInterface(rc(t), t)
}
func BenchmarkRedisCacheWithMapInterface(b *testing.B) {
benchmarkCacheWithMapInterface(rc(b), b)
}
func TestRedisCacheWithStruct(t *testing.T) {
t.Parallel()
cacheWithStruct(rc(t), t)
}
func BenchmarkRedisCacheWithStruct(b *testing.B) {
benchmarkCacheWithStruct(rc(b), b)
}
func TestRedis_Incr(t *testing.T) {
t.Parallel()
cacheIncr(rc(t), t)
}
func BenchmarkRedis_Incr(b *testing.B) {
benchmarkCacheIncr(rc(b), b)
}
func rc(t assert.TestingT) (c Cache) {
h := "127.0.0.1"
if os.Getenv("REDIS_HOST") != "" {
h = os.Getenv("REDIS_HOST")
}
p := "6379"
if os.Getenv("REDIS_PORT") != "" {
h = os.Getenv("REDIS_PORT")
}
c, err := Redis(h + ":" + p)
isError(err, t)
return
}
func TestRedis_Tag(t *testing.T) {
t.Parallel()
cacheTag(rc(t), t)
}
func BenchmarkRedis_Tag(b *testing.B) {
benchmarkCacheTag(rc(b), b)
}