- move Cacher from globals to api
- vendorPromotionID for CreatePromotion - LockPromotionSkus
This commit is contained in:
45
business/jxutils/cache/redis/redis_test.go
vendored
45
business/jxutils/cache/redis/redis_test.go
vendored
@@ -3,12 +3,16 @@ package redis
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/cache"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"git.rosy.net.cn/jx-callback/globals/beegodb"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
var (
|
||||
cacher cache.ICacher
|
||||
)
|
||||
|
||||
func init() {
|
||||
//E:/goprojects/src/git.rosy.net.cn/jx-callback/conf/app.conf
|
||||
///Users/xujianhua/go/src/git.rosy.net.cn/jx-callback/conf/app.conf
|
||||
@@ -17,7 +21,9 @@ func init() {
|
||||
|
||||
globals.Init()
|
||||
beegodb.Init()
|
||||
api.Init()
|
||||
// api.Init()
|
||||
|
||||
cacher = New("localhost", 6379, "")
|
||||
}
|
||||
|
||||
type FuckYou struct {
|
||||
@@ -25,8 +31,7 @@ type FuckYou struct {
|
||||
}
|
||||
|
||||
func TestIt(t *testing.T) {
|
||||
cacher := New("localhost", 6379, "")
|
||||
cacher.FlushAll()
|
||||
cacher.FlushKeys("")
|
||||
if cacher.Get("key") != nil {
|
||||
t.Fatal("should get nothing")
|
||||
}
|
||||
@@ -46,3 +51,35 @@ func TestIt(t *testing.T) {
|
||||
t.Fatal("should get value")
|
||||
}
|
||||
}
|
||||
|
||||
func TestKeys(t *testing.T) {
|
||||
cacher.FlushKeys("")
|
||||
keys, err := cacher.Keys("")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(keys) != 0 {
|
||||
t.Fatal("keys should be empty here")
|
||||
}
|
||||
cacher.Set("key1", 1, 0)
|
||||
cacher.Set("key2", 2, 0)
|
||||
cacher.Set("key22", 3, 0)
|
||||
cacher.Set("key23", 4, 0)
|
||||
cacher.Set("key24", 5, 0)
|
||||
keys, err = cacher.Keys("")
|
||||
if len(keys) != 5 {
|
||||
t.Fatal("keys should be 5 here")
|
||||
}
|
||||
keys, err = cacher.Keys("key")
|
||||
if len(keys) != 5 {
|
||||
t.Fatal("keys should be 5 here")
|
||||
}
|
||||
keys, err = cacher.Keys("key2")
|
||||
if len(keys) != 4 {
|
||||
t.Fatal("keys should be 4 here")
|
||||
}
|
||||
keys, err = cacher.Keys("key22")
|
||||
if len(keys) != 1 {
|
||||
t.Fatal("keys should be 1 here")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user