grpctest

package
v0.0.0-...-9112108 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package grpctest is a utility for testing gRPC and Gateway services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// RegisterServicesFunc will be called when the server is created to register services. Every new session calls this
	// function.
	RegisterServicesFunc RegisterFunc
	// contains filtered or unexported fields
}

Manager is a manager that controls a test gRPC server and the gateway that runs services.

NOTE: This manager works with a *testing.T object to log failurs and mark tests as failed. This field is optional and when it is not available, panics are used instead. This is not a very idiomatic behavior however it simplifies the tests and these panics are indeed unexpected behavior that require author's attention as soon as possible.

func NewManager

func NewManager(t *testing.T, name string, registerFunc RegisterFunc) *Manager

NewManager creates a new manager instance without starting it.

func (*Manager) Active

func (m *Manager) Active() bool

Active returns whether or not the server is running and available.

func (*Manager) ClientConnection

func (m *Manager) ClientConnection() *grpc.ClientConn

ClientConnection creates a gRPC client connection for the current server.

func (*Manager) SetT

func (m *Manager) SetT(tt *testing.T)

func (*Manager) Start

func (m *Manager) Start()

Start is idempotent. If an existing server is available, it does nothing.

func (*Manager) Stop

func (m *Manager) Stop()

type RegisterFunc

type RegisterFunc func(*grpc.Server)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL