flowtest

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package flowtest is what the tests of the adapters of docflow share: a manager over a store of a temporary directory, served over HTTP, with a clock of its own, and the far sides an exit sends to, in the process (an SMTP server, a web hook).

Index

Constants

View Source
const AdminToken = "admin-token-for-tests"

AdminToken authorizes the API of an Env.

Variables

This section is empty.

Functions

func Doc

func Doc(t *testing.T, pages int) []byte

Doc is a .bdf document of pages.

func Header(data, name string) string

Header is the value of a header of a mail.

Types

type Env

type Env struct {
	T    *testing.T
	St   *docflow.Store
	Opts docflow.Options
	Srv  *httptest.Server
	// contains filtered or unexported fields
}

Env is a manager's store served over HTTP; every request makes a manager of its own, as a function of a serverless platform would.

func New

func New(t *testing.T, edit func(*docflow.Options)) *Env

New makes an Env; edit changes its options.

func (*Env) Advance

func (e *Env) Advance(d time.Duration)

Advance moves the clock.

func (*Env) Delivery

func (e *Env) Delivery(j *docflow.Job, node string) *docflow.Delivery

Delivery is the delivery of the job's leg at a node (the first).

func (*Env) Job

func (e *Env) Job(number int32) *docflow.Job

Job is a job as it is now.

func (*Env) M

func (e *Env) M() *docflow.Manager

M is a manager of the store.

func (*Env) Now

func (e *Env) Now() time.Time

Now is the Env's clock.

func (*Env) Payload

func (e *Env) Payload(id string) []byte

Payload reads a payload's bytes.

func (*Env) Put

func (e *Env) Put(nodes ...docflow.Node) string

Put puts nodes, in order, and returns the key of the last keyed one.

func (*Env) Required

func (e *Env) Required(valid docflow.Node)

Required checks the settings a kind says are required (Kind.Required, as the editor marks them) against its Check: valid is put, and none of those settings is left out of it (those whose If its settings fit) but the node is refused.

func (*Env) Submit

func (e *Env) Submit(dest, name string, doc []byte, meta map[string]any) *docflow.Job

Submit sends a document to a destination.

func (*Env) Tick

func (e *Env) Tick()

Tick ticks until a tick sends nothing more (the steps make deliveries the next tick sends), five times at most.

type Hook

type Hook struct {
	*httptest.Server
	// contains filtered or unexported fields
}

Hook is a web service that records what it gets and answers the statuses given, in turn (the last one after).

func NewHook

func NewHook(t *testing.T, statuses ...int) *Hook

NewHook starts a Hook.

func (*Hook) Got

func (h *Hook) Got() []Request

Got are the requests the Hook got.

type Mail

type Mail struct {
	From string
	To   []string
	Auth string
	Data string
}

Mail is a mail an SMTP server got.

type Request

type Request struct {
	Method, Path, Query string
	Header              http.Header
	Body                []byte
}

Request is a request a Hook got.

type SMTP

type SMTP struct {
	Addr   string
	Refuse string
	// contains filtered or unexported fields
}

SMTP is an SMTP server of one connection at a time, that takes AUTH PLAIN and refuses the recipients of Refuse with 550.

func NewSMTP

func NewSMTP(t *testing.T) *SMTP

NewSMTP starts an SMTP server on the loopback.

func (*SMTP) Mails

func (s *SMTP) Mails() []Mail

Mails are the mails the server got.

Jump to

Keyboard shortcuts

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