forked from soyking/e3ch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_test.go
65 lines (57 loc) · 997 Bytes
/
get_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
56
57
58
59
60
61
62
63
64
65
package client
import (
"go.etcd.io/etcd/clientv3"
. "gopkg.in/check.v1"
)
const (
TEST_GET_KEY = "/get_key"
TEST_GET_VALUE = "def"
)
type GetSuite struct{}
func (s *GetSuite) SetUpSuite(c *C) {
_, err := client.client.Put(client.ctx, TEST_ROOT_KEY+TEST_GET_KEY, TEST_GET_VALUE)
if err != nil {
c.Error(err)
}
}
func (s *GetSuite) TearDownSuite(c *C) {
_, err := client.client.Delete(client.ctx, TEST_ROOT_KEY+TEST_GET_KEY, clientv3.WithPrefix())
if err != nil {
c.Error(err)
}
}
func (s *GetSuite) TestGet1(c *C) {
_, err := client.Get(TEST_GET_KEY + "a")
c.Assert(
err,
Equals,
ErrorKeyNotFound,
)
}
func (s *GetSuite) TestGet2(c *C) {
node, err := client.Get("/")
c.Assert(
err,
Equals,
nil,
)
// rootKey
c.Assert(
string(node.Value),
Equals,
client.dirValue,
)
}
func (s *GetSuite) TestGet3(c *C) {
node, err := client.Get(TEST_GET_KEY)
c.Assert(
err,
Equals,
nil,
)
c.Assert(
string(node.Value),
Equals,
TEST_GET_VALUE,
)
}