-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_test.go
More file actions
65 lines (62 loc) · 1.19 KB
/
client_test.go
File metadata and controls
65 lines (62 loc) · 1.19 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package red_test
import (
"github.com/og/gored"
"github.com/og/x/test"
"testing"
)
var c red.Client
func init () {
var err error
c, err = red.NewPool(red.PoolConfig{
Network: "tcp",
Addr: "127.0.0.1:6379",
PoolSize: 10,
PoolOpts: nil,
})
if err != nil {panic(err)}
}
func TestNewClient(t *testing.T) {
as := gtest.NewAS(t)
{
c, err := red.NewPool(red.PoolConfig{
Network: "tcp",
Addr: "127.0.0.1:1111",
PoolSize: 10,
PoolOpts: nil,
})
as.ErrorString( err, "dial tcp 127.0.0.1:1111: connect: connection refused")
_=c
}
{
c, err := red.NewPool(red.PoolConfig{
Network: "tcp",
Addr: "127.0.0.1:6379",
PoolSize: 10,
PoolOpts: nil,
})
as.NoError(err)
_ = c
}
}
func TestClient_Ping(t *testing.T) {
as := gtest.NewAS(t)
{
c, err := red.NewPool(red.PoolConfig{
Network: "tcp",
Addr: "127.0.0.1:6379",
PoolSize: 10,
PoolOpts: nil,
})
as.NoError(err)
as.NoError(c.Close())// 关闭后再ping
as.ErrorString(c.Ping(), "client is closed")
}
c, err := red.NewPool(red.PoolConfig{
Network: "tcp",
Addr: "127.0.0.1:6379",
PoolSize: 10,
PoolOpts: nil,
})
as.NoError(err)
as.NoError(c.Ping())
}