-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrecipes_test.go
More file actions
40 lines (31 loc) · 816 Bytes
/
Copy pathrecipes_test.go
File metadata and controls
40 lines (31 loc) · 816 Bytes
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
package zkclient
import (
"testing"
"time"
"github.com/funkygao/assert"
"github.com/funkygao/go-zookeeper/zk"
)
func TestRecipeCreateLiveNode(t *testing.T) {
c := New(testZkSvr, WithSessionTimeout(time.Second))
assert.Equal(t, nil, c.Connect())
c.WaitUntilConnected(0)
now := time.Now()
path := "/TestRecipeCreateLiveNode" + now.Format("20060102150405")
data := []byte(c.SessionID())
defer func() {
c.Connect()
c.DeleteTree(path)
}()
assert.Equal(t, nil, c.CreateLiveNode(path, data, 5))
c.Disconnect()
for i := 0; i < 5; i++ {
c.Connect()
assert.Equal(t, nil, c.CreateLiveNode(path, data, 5))
c.Disconnect()
}
assert.Equal(t, nil, c.Connect())
for i := 0; i < 2; i++ {
err := c.CreateLiveNode(path, data, 2)
assert.Equal(t, true, err == nil || err == zk.ErrNodeExists)
}
}