1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-03-17 21:07:54 +02:00

add test recovery (#1004)

* add middle/validate test

* add middle/recovery test
This commit is contained in:
miya 2021-06-03 23:38:54 -05:00 committed by GitHub
parent 97946ddcbd
commit 0f011ad688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,21 @@
package recovery
import (
"context"
"testing"
)
func TestOnce(t *testing.T) {
defer func() {
if recover() != nil {
t.Error("fail")
}
}()
next := func(ctx context.Context, req interface{}) (interface{}, error) {
panic("panic reason")
}
next = Recovery()(next)
_, e := next(context.Background(), "panic")
t.Logf("succ and reason is %v", e)
}