Documentation
¶
Overview ¶
Package testserver starts a real motte server in the process of a caller's test.
Index ¶
- Constants
- type Limits
- type Option
- type Server
- func (s *Server) Client(token string, opts ...client.Option) *client.Client
- func (s *Server) ImportGrant(t testing.TB, repo string) string
- func (s *Server) MergeGrant(t testing.TB, repo string) string
- func (s *Server) Mint(t testing.TB, signer grant.Signer, c grant.Claims) string
- func (s *Server) NodeGrant(t testing.TB, workspace string, epoch uint64, repo string) string
- func (s *Server) OperatorGrant(t testing.TB) string
- func (s *Server) ReadGrant(t testing.TB, repo string) string
- func (s *Server) WriteGrant(t testing.TB, repo string) string
Constants ¶
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 Limits ¶ added in v0.19.0
type Limits struct {
// Object is the largest object that a put accepts, in bytes.
Object int
// Window bounds the JSON text that the decoder holds for one object, in bytes.
Window int64
// TreeFirst is the first reservation of a tree read, and TreeFixed the fixed part of every later one, in bytes.
TreeFirst, TreeFixed int64
}
Limits lowers the size limits of one test, so that it crosses the same boundaries with small bodies. A zero field keeps the limit. The limits are process-wide and return when the test ends, so a test that sets them must not run in parallel with another test of the package that sends large bodies.
type Option ¶ added in v0.19.0
type Option func(*options)
Option changes how New starts a server.
func Required ¶ added in v0.19.0
func Required() Option
Required makes a missing PostgreSQL database fail the test instead of skipping it.
func Template ¶ added in v0.19.0
Template starts a SQLite server from a copy of the migrated database file at path. It has no effect on PostgreSQL.
func WithLimits ¶ added in v0.19.0
WithLimits lowers the size limits of the server for the test.
func WithPostgres ¶ added in v0.19.0
WithPostgres runs the server on a fresh schema of the PostgreSQL database at dsn. An empty dsn is read from DSNEnv, and then from the throwaway cluster of the package. Without a database the test skips, unless Required is set.
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 New ¶ added in v0.19.0
New runs a server on a temporary SQLite database and a temporary filesystem bucket, or on PostgreSQL with WithPostgres.
func Start ¶
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
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
StartLocalWith is StartLocal with a change to the server configuration. A nil change leaves it as is.
func (*Server) ImportGrant ¶
ImportGrant mints an import grant.
func (*Server) MergeGrant ¶ added in v0.6.0
MergeGrant mints a merge grant.
func (*Server) OperatorGrant ¶
OperatorGrant mints an operator grant.