File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -747,11 +747,15 @@ func testDB_Close_PendingTx(t *testing.T, writable bool) {
747
747
}
748
748
749
749
// Open update in separate goroutine.
750
+ startCh := make (chan struct {}, 1 )
750
751
done := make (chan error , 1 )
751
752
go func () {
753
+ startCh <- struct {}{}
752
754
err := db .Close ()
753
755
done <- err
754
756
}()
757
+ // wait for the above goroutine to get scheduled.
758
+ <- startCh
755
759
756
760
// Ensure database hasn't closed.
757
761
time .Sleep (100 * time .Millisecond )
@@ -775,14 +779,13 @@ func testDB_Close_PendingTx(t *testing.T, writable bool) {
775
779
}
776
780
777
781
// Ensure database closed now.
778
- time .Sleep (100 * time .Millisecond )
779
782
select {
780
783
case err := <- done :
781
784
if err != nil {
782
785
t .Fatalf ("error from inside goroutine: %v" , err )
783
786
}
784
- default :
785
- t .Fatal ("database did not close" )
787
+ case <- time . After ( 5 * time . Second ) :
788
+ t .Fatalf ("database did not close" )
786
789
}
787
790
}
788
791
You can’t perform that action at this time.
0 commit comments