Add a util.Forever variant that ends on a stop channel

This commit is contained in:
Clayton Coleman
2014-11-28 15:14:49 -05:00
parent 6aabd9804f
commit 740b824ac2
2 changed files with 32 additions and 0 deletions

View File

@@ -24,6 +24,26 @@ import (
"gopkg.in/v1/yaml"
)
func TestUntil(t *testing.T) {
ch := make(chan struct{})
close(ch)
Until(func() {
t.Fatal("should not have been invoked")
}, 0, ch)
ch = make(chan struct{})
called := make(chan struct{})
go func() {
Until(func() {
called <- struct{}{}
}, 0, ch)
close(called)
}()
<-called
close(ch)
<-called
}
func TestHandleCrash(t *testing.T) {
count := 0
expect := 10