forked from CodisLabs/codis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxy_test.go
48 lines (37 loc) · 879 Bytes
/
proxy_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
// Copyright 2014 Wandoujia Inc. All Rights Reserved.
// Licensed under the MIT (MIT-LICENSE.txt) license.
package models
import (
"testing"
"github.com/ngaut/zkhelper"
)
func TestProxy(t *testing.T) {
fakeZkConn := zkhelper.NewConn()
pi := &ProxyInfo{
Id: "proxy_1",
Addr: "localhost:1234",
State: PROXY_STATE_OFFLINE,
}
_, err := CreateProxyInfo(fakeZkConn, productName, pi)
if err != nil {
t.Error(err)
}
ps, err := ProxyList(fakeZkConn, productName, nil)
if err != nil {
t.Error(err)
}
if len(ps) != 1 || ps[0].Id != "proxy_1" {
t.Error("create proxy error")
}
err = SetProxyStatus(fakeZkConn, productName, pi.Id, PROXY_STATE_ONLINE)
if err != nil {
t.Error(err)
}
p, err := GetProxyInfo(fakeZkConn, productName, pi.Id)
if err != nil {
t.Error(err)
}
if p.State != PROXY_STATE_ONLINE {
t.Error("change status error")
}
}