diff options
Diffstat (limited to 'vendor/github.com/lib/pq/notify_test.go')
-rw-r--r-- | vendor/github.com/lib/pq/notify_test.go | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/vendor/github.com/lib/pq/notify_test.go b/vendor/github.com/lib/pq/notify_test.go index fe8941a4e..82a77e1eb 100644 --- a/vendor/github.com/lib/pq/notify_test.go +++ b/vendor/github.com/lib/pq/notify_test.go @@ -7,7 +7,6 @@ import ( "os" "runtime" "sync" - "sync/atomic" "testing" "time" ) @@ -235,15 +234,10 @@ func TestConnExecDeadlock(t *testing.T) { // calls Close on the net.Conn; equivalent to a network failure l.Close() - var done int32 = 0 - go func() { - time.Sleep(10 * time.Second) - if atomic.LoadInt32(&done) != 1 { - panic("timed out") - } - }() + defer time.AfterFunc(10*time.Second, func() { + panic("timed out") + }).Stop() wg.Wait() - atomic.StoreInt32(&done, 1) } // Test for ListenerConn being closed while a slow query is executing @@ -271,15 +265,11 @@ func TestListenerConnCloseWhileQueryIsExecuting(t *testing.T) { if err != nil { t.Fatal(err) } - var done int32 = 0 - go func() { - time.Sleep(10 * time.Second) - if atomic.LoadInt32(&done) != 1 { - panic("timed out") - } - }() + + defer time.AfterFunc(10*time.Second, func() { + panic("timed out") + }).Stop() wg.Wait() - atomic.StoreInt32(&done, 1) } func TestNotifyExtra(t *testing.T) { |