1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-11 04:30:39 +00:00
This commit is contained in:
JessonChan
2016-03-25 10:56:15 +08:00
parent 94bde3a777
commit 2db8c753fd
8 changed files with 42 additions and 41 deletions

14
cache/cache_test.go vendored
View File

@ -26,7 +26,7 @@ func TestCache(t *testing.T) {
t.Error("init err")
}
timeoutDuration := 10 * time.Second
if err = bm.Put("astaxie", 1, timeoutDuration); err != nil {
if err = bm.Put("astaxie", 1, timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
if !bm.IsExist("astaxie") {
@ -43,7 +43,7 @@ func TestCache(t *testing.T) {
t.Error("check err")
}
if err = bm.Put("astaxie", 1, timeoutDuration); err != nil {
if err = bm.Put("astaxie", 1, timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
@ -68,7 +68,7 @@ func TestCache(t *testing.T) {
}
//test GetMulti
if err = bm.Put("astaxie", "author", timeoutDuration); err != nil {
if err = bm.Put("astaxie", "author", timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
if !bm.IsExist("astaxie") {
@ -78,7 +78,7 @@ func TestCache(t *testing.T) {
t.Error("get err")
}
if err = bm.Put("astaxie1", "author1", timeoutDuration); err != nil {
if err = bm.Put("astaxie1", "author1", timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
if !bm.IsExist("astaxie1") {
@ -103,7 +103,7 @@ func TestFileCache(t *testing.T) {
t.Error("init err")
}
timeoutDuration := 10 * time.Second
if err = bm.Put("astaxie", 1, timeoutDuration); err != nil {
if err = bm.Put("astaxie", 1, timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
if !bm.IsExist("astaxie") {
@ -135,7 +135,7 @@ func TestFileCache(t *testing.T) {
}
//test string
if err = bm.Put("astaxie", "author", timeoutDuration); err != nil {
if err = bm.Put("astaxie", "author", timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
if !bm.IsExist("astaxie") {
@ -146,7 +146,7 @@ func TestFileCache(t *testing.T) {
}
//test GetMulti
if err = bm.Put("astaxie1", "author1", timeoutDuration); err != nil {
if err = bm.Put("astaxie1", "author1", timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
if !bm.IsExist("astaxie1") {

View File

@ -30,7 +30,7 @@ func TestMemcacheCache(t *testing.T) {
t.Error("init err")
}
timeoutDuration := 10 * time.Second
if err = bm.Put("astaxie", "1", timeoutDuration); err != nil {
if err = bm.Put("astaxie", "1", timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
if !bm.IsExist("astaxie") {
@ -42,7 +42,7 @@ func TestMemcacheCache(t *testing.T) {
if bm.IsExist("astaxie") {
t.Error("check err")
}
if err = bm.Put("astaxie", "1", timeoutDuration); err != nil {
if err = bm.Put("astaxie", "1", timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
@ -71,7 +71,7 @@ func TestMemcacheCache(t *testing.T) {
}
//test string
if err = bm.Put("astaxie", "author", timeoutDuration); err != nil {
if err = bm.Put("astaxie", "author", timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
if !bm.IsExist("astaxie") {
@ -83,7 +83,7 @@ func TestMemcacheCache(t *testing.T) {
}
//test GetMulti
if err = bm.Put("astaxie1", "author1", timeoutDuration); err != nil {
if err = bm.Put("astaxie1", "author1", timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
if !bm.IsExist("astaxie1") {

View File

@ -29,7 +29,7 @@ func TestRedisCache(t *testing.T) {
t.Error("init err")
}
timeoutDuration := 10 * time.Second
if err = bm.Put("astaxie", 1, timeoutDuration); err != nil {
if err = bm.Put("astaxie", 1, timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
if !bm.IsExist("astaxie") {
@ -41,7 +41,7 @@ func TestRedisCache(t *testing.T) {
if bm.IsExist("astaxie") {
t.Error("check err")
}
if err = bm.Put("astaxie", 1, timeoutDuration); err != nil {
if err = bm.Put("astaxie", 1, timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
@ -70,7 +70,7 @@ func TestRedisCache(t *testing.T) {
}
//test string
if err = bm.Put("astaxie", "author", timeoutDuration); err != nil {
if err = bm.Put("astaxie", "author", timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
if !bm.IsExist("astaxie") {
@ -82,7 +82,7 @@ func TestRedisCache(t *testing.T) {
}
//test GetMulti
if err = bm.Put("astaxie1", "author1", timeoutDuration); err != nil {
if err = bm.Put("astaxie1", "author1", timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
if !bm.IsExist("astaxie1") {

View File

@ -19,7 +19,7 @@ func TestSsdbcacheCache(t *testing.T) {
}
timeoutDuration := 10 * time.Second
//timeoutDuration := -10*time.Second if timeoutDuration is negtive,it means permanent
if err = ssdb.Put("ssdb", "ssdb", timeoutDuration); err != nil {
if err = ssdb.Put("ssdb", "ssdb", timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
if !ssdb.IsExist("ssdb") {
@ -27,7 +27,7 @@ func TestSsdbcacheCache(t *testing.T) {
}
// Get test done
if err = ssdb.Put("ssdb", "ssdb", timeoutDuration); err != nil {
if err = ssdb.Put("ssdb", "ssdb", timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
@ -36,7 +36,7 @@ func TestSsdbcacheCache(t *testing.T) {
}
//inc/dec test done
if err = ssdb.Put("ssdb", "2", timeoutDuration); err != nil {
if err = ssdb.Put("ssdb", "2", timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
if err = ssdb.Incr("ssdb"); err != nil {
@ -52,7 +52,7 @@ func TestSsdbcacheCache(t *testing.T) {
}
// test del
if err = ssdb.Put("ssdb", "3", timeoutDuration); err != nil {
if err = ssdb.Put("ssdb", "3", timeoutDuration*time.Second); err != nil {
t.Error("set Error", err)
}
if v, err := strconv.Atoi(ssdb.Get("ssdb").(string)); err != nil || v != 3 {