Documentation
¶
Overview ¶
Package grpct provides test helpers for gRPC server and client operations. It creates mock gRPC servers on random local ports for testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestServer ¶
TestServer creates and starts a gRPC server with the provided service, returning both the server and a configured client. The server listens on a random local port and is automatically shut down when the test completes.
Types ¶
type MockServer ¶
MockServer provides a mock gRPC server for testing. It allows registering handlers for specific endpoints.
func NewMock ¶
func NewMock(t *test.Test) (*MockServer, *client.Client)
NewMock creates a new mock gRPC server and client pair. The server listens on a random local port and is automatically shut down when the test completes.
func (*MockServer) Mock ¶
func (m *MockServer) Mock(endpoint string, handler any) *MockServer
Mock registers a handler for the specified endpoint. Returns the MockServer for method chaining.