aboutsummaryrefslogtreecommitdiffstats
path: root/remote_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'remote_test.go')
-rw-r--r--remote_test.go27
1 files changed, 19 insertions, 8 deletions
diff --git a/remote_test.go b/remote_test.go
index d0c8fa8..751c89a 100644
--- a/remote_test.go
+++ b/remote_test.go
@@ -535,10 +535,22 @@ func (s *RemoteSuite) TestPushContext(c *C) {
})
c.Assert(err, IsNil)
- // let the goroutine from pushHashes finish and check that the number of
- // goroutines is the same as before
- time.Sleep(100 * time.Millisecond)
- c.Assert(runtime.NumGoroutine(), Equals, numGoroutines)
+ eventually(c, func() bool {
+ return runtime.NumGoroutine() <= numGoroutines
+ })
+}
+
+func eventually(c *C, condition func() bool) {
+ select {
+ case <-time.After(5 * time.Second):
+ default:
+ if condition() {
+ break
+ }
+ time.Sleep(100 * time.Millisecond)
+ }
+
+ c.Assert(condition(), Equals, true)
}
func (s *RemoteSuite) TestPushContextCanceled(c *C) {
@@ -566,10 +578,9 @@ func (s *RemoteSuite) TestPushContextCanceled(c *C) {
})
c.Assert(err, Equals, context.Canceled)
- // let the goroutine from pushHashes finish and check that the number of
- // goroutines is the same as before
- time.Sleep(100 * time.Millisecond)
- c.Assert(runtime.NumGoroutine(), Equals, numGoroutines)
+ eventually(c, func() bool {
+ return runtime.NumGoroutine() <= numGoroutines
+ })
}
func (s *RemoteSuite) TestPushTags(c *C) {