1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/shirdonl-captchas_with_go

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
storeredis_test.go 1.2 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
shirdonliao Отправлено 07.07.2019 11:16 b288c8e
//++++++++++++++++++++++++++++++++++++++++
//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 TestRedisStore(t *testing.T) {
storeConfig := &StoreConfig{}
storeConfig.CaptchaConfig.LifeTime = time.Second * 100
storeConfig.Engine = "redis"
storeConfig.Servers = []string{"127.0.0.1:6379"}
store, _ := CreateCaptchaRedisStore(storeConfig)
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 redis:%#v", retV)
//test del
store.Del(key)
retV = store.Get(key)
if nil != retV {
t.Errorf("not del")
}
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/shirdonl-captchas_with_go.git
git@api.gitlife.ru:oschina-mirror/shirdonl-captchas_with_go.git
oschina-mirror
shirdonl-captchas_with_go
shirdonl-captchas_with_go
master