forked from hanguofeng/gocaptcha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcstore_test.go
45 lines (34 loc) · 920 Bytes
/
mcstore_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// 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 (
"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")
}
}