12345678910111213141516171819202122232425262728293031 |
- package serverinterceptors
- import (
- "context"
- "testing"
- "git.i2edu.net/i2/go-zero/core/logx"
- "github.com/stretchr/testify/assert"
- "google.golang.org/grpc"
- )
- func init() {
- logx.Disable()
- }
- func TestStreamCrashInterceptor(t *testing.T) {
- err := StreamCrashInterceptor(nil, nil, nil, func(
- srv interface{}, stream grpc.ServerStream) error {
- panic("mock panic")
- })
- assert.NotNil(t, err)
- }
- func TestUnaryCrashInterceptor(t *testing.T) {
- interceptor := UnaryCrashInterceptor()
- _, err := interceptor(context.Background(), nil, nil,
- func(ctx context.Context, req interface{}) (interface{}, error) {
- panic("mock panic")
- })
- assert.NotNil(t, err)
- }
|