加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mcstore_test.go 1.04 KB
一键复制 编辑 原始数据 按行查看 历史
shirdon 提交于 2019-07-07 16:16 . commit
//++++++++++++++++++++++++++++++++++++++++
//Fighting for great,share generate value!
//Build the best soft by golang,let's go!
//++++++++++++++++++++++++++++++++++++++++
//Author:ShirDon <http://www.shirdon.com>
//Email:hcbsts@163.com; 823923263@qq.com
//++++++++++++++++++++++++++++++++++++++++
package captchas_with_go
import (
"testing"
"time"
)
func TestMCStore(t *testing.T) {
memcacheServers := []string{"127.0.0.1:11211"}
store := CreateMCStore(100*time.Second, memcacheServers) //100 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.Text != captcha.Text {
t.Errorf("not equal,retV:%#v,captcha:%#v", retV, captcha)
}
retV.Text = "world"
store.Update(key, retV)
retV = store.Get(key)
if retV.Text != "world" {
t.Errorf("update not equal,retV:%#v,captcha:%#v", retV, captcha)
}
t.Logf("TestMCStore:get from mc:%#v", retV)
//test del
store.Del(key)
retV = store.Get(key)
if nil != retV {
t.Errorf("not del")
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化