lib/storage: wait for all the goroutines to finish in TestSearch in order to prevent racy behavior on test finish

This commit is contained in:
Aliaksandr Valialkin 2020-05-15 12:12:01 +03:00
parent 67e331ac62
commit 2cf2e9955b

View File

@ -168,16 +168,20 @@ func testSearchGeneric(t *testing.T, forcePerDayInvertedIndex bool) {
ch <- testSearchInternal(st, tr, mrs, accountsCount)
}()
}
var firstError error
for i := 0; i < cap(ch); i++ {
select {
case err := <-ch:
if err != nil {
t.Fatalf("unexpected error: %s", err)
if err != nil && firstError == nil {
firstError = err
}
case <-time.After(10 * time.Second):
t.Fatalf("timeout")
}
}
if firstError != nil {
t.Fatalf("unexpected error: %s", firstError)
}
})
}