Skip to content
This repository was archived by the owner on Aug 17, 2020. It is now read-only.

Commit b264cfe

Browse files
committed
Panic handler test in scope
1 parent 0cd70cd commit b264cfe

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

reflection/panic_handler_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
1-
package reflection
1+
package reflection_test
22

33
import (
4-
"fmt"
54
"sync/atomic"
65
"testing"
76
"time"
7+
8+
_ "go.undefinedlabs.com/scopeagent/autoinstrument"
9+
"go.undefinedlabs.com/scopeagent/reflection"
810
)
911

1012
func TestPanicHandler(t *testing.T) {
1113
var panicHandlerVisit int32
1214

13-
AddPanicHandler(func(e interface{}) {
14-
fmt.Println("PANIC HANDLER FOR:", e)
15+
reflection.AddPanicHandler(func(e interface{}) {
16+
t.Log("PANIC HANDLER FOR:", e)
1517
atomic.AddInt32(&panicHandlerVisit, 1)
1618
})
1719

18-
t.Run("OnPanic", func(t *testing.T) {
20+
t.Run("OnPanic", func(t2 *testing.T) {
1921
go func() {
2022

2123
defer func() {
2224
if r := recover(); r != nil {
23-
fmt.Println("PANIC RECOVERED")
25+
t.Log("PANIC RECOVERED")
2426
}
2527
}()
2628

27-
fmt.Println("PANICKING!")
29+
t.Log("PANICKING!")
2830
panic("Panic error")
2931

3032
}()

0 commit comments

Comments
 (0)