Skip to content

Commit 83ae6a7

Browse files
committed
fix TestCheckGoroutinesLeak
1 parent 2439d67 commit 83ae6a7

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

internal/xtest/leak_test.go

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,15 @@ func TestCheckGoroutinesLeak(t *testing.T) {
3030
})
3131
t.Run("NoLeak", func(t *testing.T) {
3232
TestManyTimes(t, func(t testing.TB) {
33-
var (
34-
leakDetected atomic.Bool
35-
ch = make(chan struct{})
36-
)
37-
func() {
38-
defer func() {
39-
if err := findGoroutinesLeak(); err != nil {
40-
leakDetected.Store(true)
41-
}
42-
}()
43-
defer func() {
44-
<-ch
45-
}()
46-
go func() {
47-
close(ch)
48-
}()
33+
defer func() {
34+
require.NoError(t, findGoroutinesLeak())
35+
}()
36+
37+
ch := make(chan struct{})
38+
go func() {
39+
close(ch)
4940
}()
50-
require.False(t, leakDetected.Load())
41+
<-ch
5142
})
5243
})
5344
}

0 commit comments

Comments
 (0)