forked from alphazero/Go-Redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
synchclient_test.go
55 lines (46 loc) · 1.05 KB
/
synchclient_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
46
47
48
49
50
51
52
53
54
55
package redis
import (
"log"
"testing"
)
type tspec_sct struct {
host string
port int
password string
db int
connspec *ConnectionSpec
}
// default values for test
//
func testspec_sct() tspec_sct {
var spec tspec_sct
spec.host = "localhost"
spec.port = 6379
spec.db = 13
spec.password = "go-redis"
spec.connspec = DefaultSpec().Host(spec.host).Port(spec.port).Db(spec.db).Password(spec.password)
return spec
}
func TestClientConnectWithBadSpec(t *testing.T) {
spec := testspec_sct()
spec.connspec.Password("bad-password")
c, err := NewSynchClientWithSpec(spec.connspec)
if err == nil {
t.Error("BUG: Expected a RedisError")
}
if c != nil {
t.Error("BUG: client reference expected to be nil")
}
}
func TestClientConnectWithSpec(t *testing.T) {
spec := testspec_sct()
c, err := NewSynchClientWithSpec(spec.connspec)
if err != nil {
t.Error("failed to create client with spec. Error: ", err.Message())
} else if c == nil {
t.Error("BUG: client is nil")
}
}
func TestEnd_sct(t *testing.T) {
log.Println("synchclient test")
}