mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-03 00:38:40 +08:00
ae87114282
* chore: change interface{} to any * chore: update goctl version to 1.5.0 * chore: update goctl deps
30 lines
758 B
Go
30 lines
758 B
Go
package serverinterceptors
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
func TestStreamBreakerInterceptor(t *testing.T) {
|
|
err := StreamBreakerInterceptor(nil, nil, &grpc.StreamServerInfo{
|
|
FullMethod: "any",
|
|
}, func(_ any, _ grpc.ServerStream) error {
|
|
return status.New(codes.DeadlineExceeded, "any").Err()
|
|
})
|
|
assert.NotNil(t, err)
|
|
}
|
|
|
|
func TestUnaryBreakerInterceptor(t *testing.T) {
|
|
_, err := UnaryBreakerInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
|
FullMethod: "any",
|
|
}, func(_ context.Context, _ any) (any, error) {
|
|
return nil, status.New(codes.DeadlineExceeded, "any").Err()
|
|
})
|
|
assert.NotNil(t, err)
|
|
}
|