Example plan
postgres.yaml
New here? Get started. See Running the examplesfor this plan's fixture, runtime, database or browser requirements. The exec example needs no fixture; Postgres and Playwright need their optional dependencies.
Check the persisted order with a read-only Postgres role and READ ONLY transactions. Provide a dedicated test database and writer/reader roles (see Running the examples guide). In Terminal 1: bin/vero-testserver --postgres "$VERO_TEST_PG_FIXTURE_DSN" In Terminal 2: bin/vero run examples/postgres.yaml (with VERO_TEST_PG_DSN exported). The fixture writes the orders; the reader checks the stored row.
apiVersion: vero.plan/v1
kind: Plan
metadata: { name: order-is-persisted-postgres }
env:
baseUrl: http://127.0.0.1:18080
tenantId: tenant-42
lifecycle:
strategy: unique
connections:
orders: { driver: postgres, dsn: "${VERO_TEST_PG_DSN}" }
resources:
- name: db/orders
tasks:
- name: login
steps:
- http: { method: POST, url: "{{ env.baseUrl }}/auth/token", json: { key: "postgres-{{ run.id }}" } }
assert: [status == 200]
results: { token: body.token }
- name: create-order
steps:
- http:
method: POST
url: "{{ env.baseUrl }}/orders"
headers: { Authorization: "Bearer {{ tasks.login.results.token }}", X-Tenant-Id: "{{ env.tenantId }}" }
json: { sku: ABC-1, qty: 2 }
assert: [status == 201]
results: { orderId: body.order.id }
- name: order-is-persisted
needs: [create-order]
holds: [db/orders]
steps:
- sql:
connection: orders
query: |
select status, total_cents, tenant_id
from orders where id = $1
args: ["{{ tasks.create-order.results.orderId }}"]
assert:
- rows count 1
- rows[0].status == "pending"
- rows[0].total_cents == 2000
- rows[0].tenant_id == env.tenantIdThis page is examples/postgres.yaml in the repository.