You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
644 B
Go
31 lines
644 B
Go
4 years ago
|
package serverinterceptors
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
3 years ago
|
"github.com/zeromicro/go-zero/core/logx"
|
||
4 years ago
|
"google.golang.org/grpc"
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
logx.Disable()
|
||
|
}
|
||
|
|
||
|
func TestStreamCrashInterceptor(t *testing.T) {
|
||
2 years ago
|
err := StreamRecoverInterceptor(nil, nil, nil, func(
|
||
3 years ago
|
svr interface{}, stream grpc.ServerStream) error {
|
||
4 years ago
|
panic("mock panic")
|
||
|
})
|
||
|
assert.NotNil(t, err)
|
||
|
}
|
||
|
|
||
|
func TestUnaryCrashInterceptor(t *testing.T) {
|
||
2 years ago
|
_, err := UnaryRecoverInterceptor(context.Background(), nil, nil,
|
||
4 years ago
|
func(ctx context.Context, req interface{}) (interface{}, error) {
|
||
|
panic("mock panic")
|
||
|
})
|
||
4 years ago
|
assert.NotNil(t, err)
|
||
|
}
|