consul: adding StopWatch test

pull/939/head
Armon Dadgar 10 years ago
parent ab3632e409
commit cee5b53423

@ -127,6 +127,37 @@ func TestGetNodes(t *testing.T) {
} }
} }
func TestGetNodes_Watch_StopWatch(t *testing.T) {
store, err := testStateStore()
if err != nil {
t.Fatalf("err: %v", err)
}
defer store.Close()
notify1 := make(chan struct{}, 1)
notify2 := make(chan struct{}, 1)
store.Watch(store.QueryTables("Nodes"), notify1)
store.Watch(store.QueryTables("Nodes"), notify2)
store.StopWatch(store.QueryTables("Nodes"), notify2)
if err := store.EnsureNode(40, structs.Node{"foo", "127.0.0.1"}); err != nil {
t.Fatalf("err: %v", err)
}
select {
case <-notify1:
default:
t.Fatalf("should be notified")
}
select {
case <-notify2:
t.Fatalf("should not be notified")
default:
}
}
func BenchmarkGetNodes(b *testing.B) { func BenchmarkGetNodes(b *testing.B) {
store, err := testStateStore() store, err := testStateStore()
if err != nil { if err != nil {

Loading…
Cancel
Save