wip: default writer tested
This commit is contained in:
29
log/wrapped/wrapped_test.go
Normal file
29
log/wrapped/wrapped_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package wrapped
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gitea.suyono.dev/suyono/wingmate/debugframes"
|
||||
"gitea.suyono.dev/suyono/wingmate/log"
|
||||
"runtime/debug"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPrintWrappedError(t *testing.T) {
|
||||
log.Print("test", fmt.Errorf("wrapped error trace%w", debugframes.GetTraces()))
|
||||
}
|
||||
|
||||
func TestPrintWrappedPanic(t *testing.T) {
|
||||
f := func() (err error) {
|
||||
defer func() {
|
||||
if o := recover(); o != nil {
|
||||
err = fmt.Errorf("panic: %v%w", o, debugframes.PanicTrace(debug.Stack()))
|
||||
}
|
||||
}()
|
||||
|
||||
panic("test")
|
||||
return nil
|
||||
}
|
||||
|
||||
err := f()
|
||||
log.Print("panic_test", err)
|
||||
}
|
||||
Reference in New Issue
Block a user