mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 17:20:24 +08:00
26c541b9cb
* feat: add middlewares config for zrpc * chore: add tests * chore: improve codecov * chore: improve codecov
31 lines
644 B
Go
31 lines
644 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 interface{}, 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 interface{}) (interface{}, error) {
|
|
panic("mock panic")
|
|
})
|
|
assert.NotNil(t, err)
|
|
}
|