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.
32 lines
809 B
Go
32 lines
809 B
Go
3 years ago
|
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(
|
||
|
srv interface{}, stream grpc.ServerStream) error {
|
||
|
return status.New(codes.DeadlineExceeded, "any").Err()
|
||
|
})
|
||
|
assert.NotNil(t, err)
|
||
|
}
|
||
|
|
||
|
func TestUnaryBreakerInterceptor(t *testing.T) {
|
||
|
interceptor := UnaryBreakerInterceptor()
|
||
|
_, err := interceptor(nil, nil, &grpc.UnaryServerInfo{
|
||
|
FullMethod: "any",
|
||
|
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||
|
return nil, status.New(codes.DeadlineExceeded, "any").Err()
|
||
|
})
|
||
|
assert.NotNil(t, err)
|
||
|
}
|