consul: adding StopWatch test
This commit is contained in:
parent
2c9592c5ee
commit
f91069f9d5
|
@ -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) {
|
||||
store, err := testStateStore()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue