clienttest

package
v0.72.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package clienttest is a test-only harness that wires a real protoregistry server (Postgres + gRPC over bufconn) and exposes a *grpc.ClientConn ready to be passed to client.New, plus helpers for the publish/promote dance.

The harness aborts the test (t.Fatalf) if Docker / Postgres cannot be brought up, matching the convention in the rest of the repo. Spinning up Postgres takes ~5–10s per test; consolidate scenarios into subtests under a single Start to share the container.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	Conn *grpc.ClientConn
	// contains filtered or unexported fields
}

Server bundles a running protoregistry instance and a connected gRPC client conn. Pass Conn to client.New; use the helpers below to drive the server-side state.

func Start

func Start(t *testing.T) *Server

Start brings up Postgres in a container, applies migrations, wires the registry onto a bufconn-backed gRPC server, and returns a connection ready to be passed to client.New. All resources are cleaned up via t.Cleanup.

func (*Server) CreateNamespace

func (s *Server) CreateNamespace(t *testing.T, namespace string)

CreateNamespace ensures the namespace exists. AlreadyExists is treated as benign so callers can invoke it idempotently.

func (*Server) Promote

func (s *Server) Promote(t *testing.T, namespace string)

Promote promotes all staged schemas in the namespace.

func (*Server) Publish

func (s *Server) Publish(t *testing.T, namespace, schemaID string, sources map[string][]byte) uint64

Publish stages a new version of a schema, returning the version number assigned by the server.

func (*Server) PublishAndPromote

func (s *Server) PublishAndPromote(t *testing.T, namespace, schemaID string, sources map[string][]byte) uint64

PublishAndPromote is the common test setup: ensure the namespace exists, publish, promote. Returns the published version.

func (*Server) SetNamespaceParent added in v0.71.0

func (s *Server) SetNamespaceParent(t *testing.T, namespace, parent string)

SetNamespaceParent links a namespace to a parent for chained resolution. Both namespaces must already exist.

Jump to

Keyboard shortcuts

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