awa-testing
Test utilities for the Awa job queue.
awa-testing lets you exercise job handlers and admin code paths in
unit and integration tests without spinning up the full worker
runtime. Use it for in-tree tests of the workspace, in your own
crate's tests, or anywhere you want to drive a single job through a
real Postgres without configuring queues, dispatchers, and
maintenance leaders.
The crate is dev-dependencies-shaped: there is no embedded Postgres,
you point it at a real test database (typically a local container on
port 15432).
What's in here
TestClient— synchronous-feeling wrapper around aPgPool:migrate()runs the schema and resets the runtime backend so tests start from a known state.clean()truncatesawa.jobs,awa.queue_meta, and the runtime-storage backend rows for cross-test isolation.insert(&args)enqueues one job.work_one(&worker)/work_one_in_queue(&worker, queue)claim and execute exactly one job through the suppliedWorker, returning aWorkResult(Completed,Failed,Snoozed,Cancelled,WaitingExternal,NoJob).get_job(id)returns the currentJobRow.
WorkResult— enum withis_completed(),is_failed(),is_waiting_external(),is_no_job()predicates.setupmodule —database_url(),database_url_with_app_name(),pool(),pool_with_url()helpers andreset_runtime_backend()for explicit test cleanup.
Usage
use JobArgs;
use TestClient;
use ;
;
async
See also
- Test plan
- Development
- For Python projects, the equivalent helpers live in
awa.testing.
License
MIT OR Apache-2.0