replace zxq.co/ripple/hanayo
This commit is contained in:
48
vendor/github.com/gin-gonic/contrib/cache/redis_test.go
generated
vendored
Normal file
48
vendor/github.com/gin-gonic/contrib/cache/redis_test.go
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"net"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// These tests require redis server running on localhost:6379 (the default)
|
||||
const redisTestServer = "localhost:6379"
|
||||
|
||||
var newRedisStore = func(t *testing.T, defaultExpiration time.Duration) CacheStore {
|
||||
c, err := net.Dial("tcp", redisTestServer)
|
||||
if err == nil {
|
||||
c.Write([]byte("flush_all\r\n"))
|
||||
c.Close()
|
||||
redisCache := NewRedisCache(redisTestServer, "", defaultExpiration)
|
||||
redisCache.Flush()
|
||||
return redisCache
|
||||
}
|
||||
t.Errorf("couldn't connect to redis on %s", redisTestServer)
|
||||
t.FailNow()
|
||||
panic("")
|
||||
}
|
||||
|
||||
func TestRedisCache_TypicalGetSet(t *testing.T) {
|
||||
typicalGetSet(t, newRedisStore)
|
||||
}
|
||||
|
||||
func TestRedisCache_IncrDecr(t *testing.T) {
|
||||
incrDecr(t, newRedisStore)
|
||||
}
|
||||
|
||||
func TestRedisCache_Expiration(t *testing.T) {
|
||||
expiration(t, newRedisStore)
|
||||
}
|
||||
|
||||
func TestRedisCache_EmptyCache(t *testing.T) {
|
||||
emptyCache(t, newRedisStore)
|
||||
}
|
||||
|
||||
func TestRedisCache_Replace(t *testing.T) {
|
||||
testReplace(t, newRedisStore)
|
||||
}
|
||||
|
||||
func TestRedisCache_Add(t *testing.T) {
|
||||
testAdd(t, newRedisStore)
|
||||
}
|
Reference in New Issue
Block a user