-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcodis_test.go
38 lines (31 loc) · 845 Bytes
/
codis_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
package codis
import (
"time"
"testing"
"github.com/garyburd/redigo/redis"
)
func TestGet(t *testing.T) {
var (
r redis.Conn
p *Pool = &Pool{
ZkServers: []string{"127.0.0.1:2181"},
ZkTimeout: time.Second * 10,
ZkDir: "/codis/proxy",
Dial: func(network, address string) (redis.Conn, error) {
conn, err := redis.Dial(network, address)
if err == nil {
conn.Send("AUTH", "PASSWORD")
}
return conn, err
},
}
test_key, test_value string = "key", "value"
)
r = p.Get()
r.Do("SET", test_key, test_value)
r = p.Get()
result_value, _ := redis.String(r.Do("GET", test_key))
if result_value != test_value {
t.Failed()
}
}