mirror of https://github.com/status-im/migrate.git
Fix memory leak in tests
- Stop leaking tickers. As the docs state, using time.Tick() will leak tickers, so use time.NewTicker() with time.Ticker.Stop(). - Be more efficient by using time.NewTimer() with time.Timer.Stop() instead of time.After().
This commit is contained in:
parent
caa5719a86
commit
d549fd5265
|
@ -48,17 +48,19 @@ func ParallelTest(t *testing.T, versions []Version, readyFn IsReadyFunc, testFn
|
|||
defer container.Remove()
|
||||
|
||||
// wait until database is ready
|
||||
tick := time.Tick(1000 * time.Millisecond)
|
||||
timeout := time.After(time.Duration(timeout) * time.Second)
|
||||
tick := time.NewTicker(1000 * time.Millisecond)
|
||||
defer tick.Stop()
|
||||
timeout := time.NewTimer(time.Duration(timeout) * time.Second)
|
||||
defer timeout.Stop()
|
||||
outer:
|
||||
for {
|
||||
select {
|
||||
case <-tick:
|
||||
case <-tick.C:
|
||||
if readyFn(container) {
|
||||
break outer
|
||||
}
|
||||
|
||||
case <-timeout:
|
||||
case <-timeout.C:
|
||||
t.Fatalf("Docker: Container not ready, timeout for %v.\n%s", version, containerLogs(t, container))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue