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 ¶
- type Server
- func (s *Server) CreateNamespace(t *testing.T, namespace string)
- func (s *Server) Promote(t *testing.T, namespace string)
- func (s *Server) Publish(t *testing.T, namespace, schemaID string, sources map[string][]byte) uint64
- func (s *Server) PublishAndPromote(t *testing.T, namespace, schemaID string, sources map[string][]byte) uint64
- func (s *Server) SetNamespaceParent(t *testing.T, namespace, parent string)
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 ¶
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 ¶
CreateNamespace ensures the namespace exists. AlreadyExists is treated as benign so callers can invoke it idempotently.
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.