go-zero/zrpc/internal/serverinterceptors/recoverinterceptor_test.go
Kevin Wan ae87114282
chore: change interface{} to any (#2818)
* chore: change interface{} to any

* chore: update goctl version to 1.5.0

* chore: update goctl deps
2023-01-24 16:32:02 +08:00

31 lines
620 B
Go

package serverinterceptors
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/logx"
"google.golang.org/grpc"
)
func init() {
logx.Disable()
}
func TestStreamCrashInterceptor(t *testing.T) {
err := StreamRecoverInterceptor(nil, nil, nil, func(
svr any, stream grpc.ServerStream) error {
panic("mock panic")
})
assert.NotNil(t, err)
}
func TestUnaryCrashInterceptor(t *testing.T) {
_, err := UnaryRecoverInterceptor(context.Background(), nil, nil,
func(ctx context.Context, req any) (any, error) {
panic("mock panic")
})
assert.NotNil(t, err)
}