testserver

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testserver starts a real motte server in the process of a caller's test.

Index

Constants

View Source
const DSNEnv = pgtest.DSNEnv

DSNEnv is the environment variable that Start reads when it gets no DSN.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	URL string
	// Pool reaches the schema of the server, for a test that sets up a state no route can make. StartLocal leaves it nil.
	Pool *pgxpool.Pool
	// Meta, Bucket and Verifier are the state and the keys of the server, for a test that runs a second replica on them
	// or sets up a state no route can make.
	Meta     meta.Store
	Bucket   bucket.Store
	Verifier *grant.Verifier
	// Operator is the control-plane signer.
	Operator grant.Signer
	// Node is the node signer.
	Node grant.Signer
	// Expire is the expiry of the grants that the helpers mint.
	Expire time.Time
}

Server is a running store. Its control-plane key signs every scope. Its node key signs only node grants.

func Start

func Start(t testing.TB, dsn string) *Server

Start runs a server on a fresh schema of the database at dsn and a temporary filesystem bucket. An empty dsn is read from DSNEnv. When that is empty too, Start skips the test. Cleanup drops the schema.

func StartLocal added in v0.6.0

func StartLocal(t testing.TB) *Server

StartLocal runs a server on a temporary SQLite database and a temporary filesystem bucket. It needs no other service and never skips. Pool is nil.

func StartLocalWith added in v0.9.0

func StartLocalWith(t testing.TB, change func(*server.Config)) *Server

StartLocalWith is StartLocal with a change to the server configuration. A nil change leaves it as is.

func (*Server) Client

func (s *Server) Client(token string, opts ...client.Option) *client.Client

Client returns a client that sends token on every call.

func (*Server) ImportGrant

func (s *Server) ImportGrant(t testing.TB, repo string) string

ImportGrant mints an import grant.

func (*Server) MergeGrant added in v0.6.0

func (s *Server) MergeGrant(t testing.TB, repo string) string

MergeGrant mints a merge grant.

func (*Server) Mint

func (s *Server) Mint(t testing.TB, signer grant.Signer, c grant.Claims) string

Mint signs c with signer and sets the expiry of the server when c has none.

func (*Server) NodeGrant

func (s *Server) NodeGrant(t testing.TB, workspace string, epoch uint64, repo string) string

NodeGrant mints a node grant with the node key.

func (*Server) OperatorGrant

func (s *Server) OperatorGrant(t testing.TB) string

OperatorGrant mints an operator grant.

func (*Server) ReadGrant

func (s *Server) ReadGrant(t testing.TB, repo string) string

ReadGrant mints a read grant.

func (*Server) WriteGrant added in v0.6.0

func (s *Server) WriteGrant(t testing.TB, repo string) string

WriteGrant mints a write grant.

Jump to

Keyboard shortcuts

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