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()resets the runtime backend and deletes through theawa.jobscompatibility surface plusawa.queue_metafor 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,Retryable,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.
TestClient is intentionally a lightweight compatibility-surface harness. It does not exercise the full dispatcher, queue-storage receipt plane, or maintenance leader; use the worker runtime or integration benchmarks when a test needs production storage-path fidelity.
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