Skip to content

Commit 7980065

Browse files
test(synctest): add synctest to syncutil test (#5259)
1 parent 72ed53f commit 7980065

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

pkg/util/syncutil/syncutil_test.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,26 @@ package syncutil
77
import (
88
"sync"
99
"testing"
10+
"testing/synctest"
1011
"time"
1112
)
1213

1314
func TestWaitWithTimeout(t *testing.T) {
1415
var wg sync.WaitGroup
1516

16-
if !WaitWithTimeout(&wg, 10*time.Millisecond) {
17-
t.Fatal("want timeout; have none")
18-
}
17+
synctest.Test(t, func(t *testing.T) {
18+
if !WaitWithTimeout(&wg, 10*time.Millisecond) {
19+
t.Fatal("want timeout; have none")
20+
}
1921

20-
wg.Add(1)
21-
if WaitWithTimeout(&wg, 10*time.Millisecond) {
22-
t.Fatal("have timeout; want none")
23-
}
22+
wg.Add(1)
23+
if WaitWithTimeout(&wg, 10*time.Millisecond) {
24+
t.Fatal("have timeout; want none")
25+
}
2426

25-
wg.Done()
26-
if !WaitWithTimeout(&wg, 10*time.Millisecond) {
27-
t.Fatal("want no timeout; have none")
28-
}
27+
wg.Done()
28+
if !WaitWithTimeout(&wg, 10*time.Millisecond) {
29+
t.Fatal("want no timeout; have none")
30+
}
31+
})
2932
}

0 commit comments

Comments
 (0)