-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathset_test.go
55 lines (41 loc) · 1022 Bytes
/
set_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
// Copyright 2018-2019 The vogo Authors. All rights reserved.
// author: wongoo
// since: 2019/10/12
//
package zkclient
import (
"testing"
"github.com/samuel/go-zookeeper/zk"
"github.com/stretchr/testify/assert"
)
func TestClient_SetTempRawValue(t *testing.T) {
if !isLocalZKAlive(t) {
return
}
path := "/temp_raw_value"
c := connectLocalZK(t)
err := c.SetTempString(path, "hello")
assert.Nil(t, err)
data, err := c.GetString(path)
assert.Nil(t, err)
assert.Equal(t, "hello", data)
c.Close()
c = connectLocalZK(t)
_, err = c.GetString(path)
assert.NotNil(t, err)
assert.Equal(t, zk.ErrNoNode, err)
}
func TestClient_SetMapStringValue(t *testing.T) {
if !isLocalZKAlive(t) {
return
}
path := "/test/set_map_string"
err := testClient.SetMapStringValue(path, "c1", "hello")
assert.Nil(t, err)
childPath := PathJoin(path, "c1")
data, err := testClient.GetString(childPath)
assert.Nil(t, err)
assert.Equal(t, "hello", data)
err = testClient.Delete(childPath)
assert.Nil(t, err)
}