-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathetcd_client_test.go
45 lines (32 loc) · 924 Bytes
/
etcd_client_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
package globe
import (
"testing"
"time"
)
// TODO: Mock things so we don't need active etcd cluster and yucky sleep
// Expects etcd to be running on the local host under port 4001
func TestEtcdClient(t *testing.T) {
client := NewEtcdClient(testCluster)
rawClient.Set("test", "value", uint64(1))
val, err := client.Get("test")
if err != nil {
t.Error(err)
}
if val.Value != "value" {
t.Errorf("Expected %s to be 'value'", val.Value)
}
client = nil
}
func TestEtcdWatch(t *testing.T) {
client := NewEtcdClient(testCluster)
watchChan := make(chan *LogNode)
go client.Watch("watchtest", watchChan, nil)
// Janky way to give our watch time to be set
time.Sleep(1000 * time.Millisecond)
rawClient.Set("watchtest", "newvalue", uint64(10))
change := <- watchChan
if change.Value != "newvalue" {
t.Errorf("Expected %s to be 'newvalue'", change.Value)
}
client = nil
}