Documentation ¶
Index ¶
- Constants
- func StartTestAppCallbackGRPCServer(t *testing.T, port int, mockServer runtimev1pb.AppCallbackServer) *grpc.Server
- func TestServerFor[TServer any, TClient any](logger logger.Logger, registersvc func(*grpc.Server, TServer), ...) func(svc TServer) (client TClient, cleanup func(), err error)
- func TestServerWithDialer[TServer any](logger logger.Logger, registersvc func(*grpc.Server, TServer)) func(svc TServer) (...)
Constants ¶
View Source
const (
MaxGRPCServerUptime = 200 * time.Millisecond
)
Variables ¶
This section is empty.
Functions ¶
func StartTestAppCallbackGRPCServer ¶ added in v1.12.0
func StartTestAppCallbackGRPCServer(t *testing.T, port int, mockServer runtimev1pb.AppCallbackServer) *grpc.Server
func TestServerFor ¶
func TestServerFor[TServer any, TClient any](logger logger.Logger, registersvc func(*grpc.Server, TServer), clientFactory func(grpc.ClientConnInterface) TClient) func(svc TServer) (client TClient, cleanup func(), err error)
TestServerFor returns a grpcServer factory that bootstraps a grpcserver backed by a buf connection (in memory), and returns the given clientFactory instance to communicate with it. it also provides cleanup function for close the grpcserver and client connection.
usage, serverFactory := testingGrpc.TestServerFor(testLogger, func(s *grpc.Server, svc *your_service_goes_here) { proto.RegisterMyService(s, svc) // your service }, proto.NewMyServiceClient) client, cleanup, err := serverFactory(&your_service{}) require.NoError(t, err) defer cleanup()
func TestServerWithDialer ¶ added in v1.10.0
func TestServerWithDialer[TServer any](logger logger.Logger, registersvc func(*grpc.Server, TServer)) func(svc TServer) (dialer func(ctx context.Context, opts ...grpc.DialOption) (*grpc.ClientConn, error), cleanup func(), err error)
TestServerWithDialer returns a grpcServer factory that bootstraps a grpcserver backed by a buf connection (in memory), and returns a connection dialer to communicate with it. it also provides cleanup function for close the grpcserver but the client connection should be handled by the caller.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.