1 Star 0 Fork 12

Doer / gocaptcha

forked from hanguofeng / gocaptcha 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
cstore_test.go 911 Bytes
一键复制 编辑 原始数据 按行查看 历史
hanguofeng 提交于 2013-09-28 23:41 . add store interface
// Copyright 2013 hanguofeng. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package gocaptcha
import (
"os"
"testing"
"time"
)
func TestStore(t *testing.T) {
store := CreateCStore(10*time.Second, 1, 100) //10 s
captcha := new(CaptchaInfo)
captcha.Text = "hello"
captcha.CreateTime = time.Now()
//test add and get
key := store.Add(captcha)
retV := store.Get(key)
if retV != captcha {
t.Errorf("not equal")
}
//test dump,destroy and loaddumped
store.Dump("data/data.dat")
store.Destroy()
retV = store.Get(key)
if nil != retV {
t.Errorf("Destroy error")
}
store.LoadDumped("data/data.dat")
retV = store.Get(key)
if captcha.Text != retV.Text {
t.Errorf("LoadDumped error")
}
os.Remove("data/data.dat")
//test del
store.Del(key)
retV = store.Get(key)
if nil != retV {
t.Errorf("not del")
}
}
1
https://gitee.com/Doer/gocaptcha.git
git@gitee.com:Doer/gocaptcha.git
Doer
gocaptcha
gocaptcha
master

搜索帮助