Documentation
¶
Overview ¶
Package acceptance is packtrail's black-box acceptance suite: every test drives a real engine, real workers and a real embedded nats-server through the public API only, with fault injection (engine kill and restart, NATS restart, duplicate and reordered completions). Each scenario pins a guaranteed behaviour.
Index ¶
- Constants
- func Echo(_ context.Context, j *worker.Job) (*worker.Result, error)
- func JSON(t *testing.T, raw json.RawMessage) any
- type Env
- func (e *Env) Completed(id string) *packtrail.State
- func (e *Env) Eventually(cond func() bool, msg func() string)
- func (e *Env) KillEngines()
- func (e *Env) NC() *nats.Conn
- func (e *Env) Register(yaml string) string
- func (e *Env) RestartEngine()
- func (e *Env) Start(flowName string, input any, opts ...packtrail.StartOption) string
- func (e *Env) StartEngine(extra ...packtrail.Option) *packtrail.Engine
- func (e *Env) Wait(id string) *packtrail.State
- func (e *Env) WaitStatus(id string, want packtrail.Status) *packtrail.State
- func (e *Env) Worker(kind string, h worker.Handler, opts ...worker.Option)
Constants ¶
const DefaultTimeout = 60 * time.Second
DefaultTimeout bounds every acceptance test.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Env ¶
type Env struct {
T *testing.T
S *natstest.Server
Ctx context.Context //nolint:containedctx // test-scoped context.
Client *packtrail.Client
// Engine is the first engine started.
Engine *packtrail.Engine
// contains filtered or unexported fields
}
Env is one test deployment.
func NewEnv ¶
NewEnv starts NATS, provisions the namespace with the given flows and starts one engine.
func (*Env) Eventually ¶
Eventually polls cond until it holds or the test context ends.
func (*Env) KillEngines ¶
func (e *Env) KillEngines()
KillEngines stops every running engine (gracefully: in-flight commands drain) and waits for them.
func (*Env) RestartEngine ¶
func (e *Env) RestartEngine()
RestartEngine replaces every engine with a fresh one.
func (*Env) StartEngine ¶
StartEngine starts another engine process (own connection).
func (*Env) WaitStatus ¶
WaitStatus waits until the execution has status want.