From 96e5302ceb3a48fc6faf6c258747a098226d1236 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 8 Sep 2020 20:27:53 +0800 Subject: [PATCH] Fix test --- integrations/session_update_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/integrations/session_update_test.go b/integrations/session_update_test.go index a707bf66..07c722bd 100644 --- a/integrations/session_update_test.go +++ b/integrations/session_update_test.go @@ -188,6 +188,9 @@ func TestForUpdate(t *testing.T) { // lock is NOT used wg.Add(1) + + wg2 := &sync.WaitGroup{} + wg2.Add(1) go func() { f3 := new(ForUpdate) session3.Where("id = ?", 1) @@ -201,10 +204,10 @@ func TestForUpdate(t *testing.T) { t.Errorf("read lock failed") } wg.Done() + wg2.Done() }() - // wait for go rountines - time.Sleep(50 * time.Millisecond) + wg2.Wait() f := new(ForUpdate) f.Name = "updated by session1"