diff --git a/middleware/recovery/recovery_test.go b/middleware/recovery/recovery_test.go new file mode 100644 index 000000000..edfcd842b --- /dev/null +++ b/middleware/recovery/recovery_test.go @@ -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) +}