Skip to content

Commit 6384160

Browse files
committed
test(gevent): update panic handling test logic in gevent_z_unit_test.go
- Changed the `panicHandled` variable from a plain boolean to `gtype.Bool` type - Use `gtype.Bool`'s `Set` and `Val` methods to set and retrieve the value of `panicHandled`
1 parent 1390e8e commit 6384160

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

os/gevent/gevent_z_unit_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"testing"
55
"time"
66

7+
"github.com/gogf/gf/v2/container/gtype"
78
"github.com/gogf/gf/v2/os/gevent"
89
"github.com/gogf/gf/v2/test/gtest"
910
)
@@ -296,9 +297,9 @@ func TestEvent_RecoverFuncAsync(t *testing.T) {
296297
gtest.C(t, func(t *gtest.T) {
297298
event := gevent.New()
298299

299-
var panicHandled bool
300+
panicHandled := gtype.NewBool()
300301
recoverFunc := func(topic string, message any) {
301-
panicHandled = true
302+
panicHandled.Set(true)
302303
}
303304

304305
handler := func(topic string, message any) {
@@ -312,7 +313,7 @@ func TestEvent_RecoverFuncAsync(t *testing.T) {
312313
t.AssertNil(err)
313314

314315
time.Sleep(10 * time.Millisecond)
315-
t.Assert(panicHandled, true)
316+
t.Assert(panicHandled.Val(), true)
316317
})
317318
}
318319

0 commit comments

Comments
 (0)