Documentation
¶
Overview ¶
Package apptest runs the whole HTTP stack against a fresh test database so API behaviour can be tested end to end: middleware, authz, handlers, SQL.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Bearer is sent as Authorization when set (API keys, agents).
Bearer string
// contains filtered or unexported fields
}
Client is a browser-like client with its own cookie jar.
func (*Client) DoRaw ¶
DoRaw sends a request with a raw body and content type (multipart uploads) to path under /api/v1, or to a non-API path as is ("/media/…").
func (*Client) SignInDemo ¶
SignInDemo signs in as a demo user. Demo users with an authenticator get a session directly (tests don't type TOTP codes).
type Env ¶
Env is a running test instance.
func (*Env) CreateUser ¶
CreateUser inserts a user directly.
func (*Env) CreateWorkspace ¶
CreateWorkspace creates a workspace owned by owner.
type Response ¶
Response is a decoded API response.
func (*Response) MustStatus ¶
MustStatus fails the test unless the response has the given status.
type SMTPSink ¶
type SMTPSink struct {
Addr string
// Reject makes AUTH fail with 535.
Reject bool
// contains filtered or unexported fields
}
SMTPSink is a minimal SMTP server for tests: it accepts EHLO, AUTH PLAIN or LOGIN (any credentials unless Reject is set), MAIL, RCPT and DATA, and keeps every message it received.
func NewSMTPSink ¶
NewSMTPSink starts a sink on a free local port; it stops with the test.
func (*SMTPSink) Messages ¶
func (s *SMTPSink) Messages() []SinkMessage
Messages returns what the sink received so far.
type SinkMessage ¶
SinkMessage is one message the sink received.