mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 09:40:24 +08:00
3b7ca86e4f
* test: add more tests * test: add more tests
30 lines
782 B
Go
30 lines
782 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(_ interface{}, _ 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, _ interface{}) (interface{}, error) {
|
|
return nil, status.New(codes.DeadlineExceeded, "any").Err()
|
|
})
|
|
assert.NotNil(t, err)
|
|
}
|