Fix adding to chanotify on blocking select

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
Alexander Morozov 2015-12-21 15:01:31 -08:00
parent d99ee27874
commit e2f3518af8
2 changed files with 25 additions and 6 deletions

View file

@ -78,3 +78,18 @@ func TestConcurrentNotifier(t *testing.T) {
}
}
}
func TestAddToBlocked(t *testing.T) {
s := New()
ch := make(chan struct{}, 1)
go func() {
// give some time to start first select
time.Sleep(1 * time.Second)
s.Add(ch, "1")
ch <- struct{}{}
}()
val := <-s.Chan()
if val != "1" {
t.Fatalf("Expected 1, got %s", val)
}
}