Example plan

orders.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.

Log in, create an order, check it, and delete it in teardown. The API key is a secret read from the environment. Start bin/vero-testserver in Terminal 1 in the foreground; in Terminal 2 run:

$ ORDERS_API_KEY=example-key-1234 bin/vero run examples/orders.yaml
apiVersion: vero.plan/v1
kind: Plan
metadata:
  name: orders-api
env:
  baseUrl: http://127.0.0.1:18080
  apiKey:
    secretRef: ORDERS_API_KEY
lifecycle:
  strategy: unique            # each run's order is new, and its SKU carries run.id

tasks:
  - name: health
    steps:
      - http: { method: GET, url: "{{ env.baseUrl }}/healthz" }
        assert: [status == 200]

  - name: login
    steps:
      - http:
          method: POST
          url: "{{ env.baseUrl }}/auth/token"
          json: { key: "{{ env.apiKey }}" }
        assert:
          - status == 200
          - body.token != nil
        results:
          token: body.token

  - name: create-order
    steps:
      - http:
          method: POST
          url: "{{ env.baseUrl }}/orders"
          headers:
            Authorization: "Bearer {{ tasks.login.results.token }}"
          json: { sku: "ABC-{{ run.id }}", qty: 2 }
        assert:
          - status == 201
          - body.order.status == "pending"
          - body.order.total == 2000
          - body matches schema "schemas/order-response.json"
        results:
          orderId: body.order.id

  - name: cleanup-check
    needs: [create-order]     # an explicit edge: ordering with no data flowing
    steps:
      - http:
          method: GET
          url: "{{ env.baseUrl }}/orders?status=pending"
          headers: { Authorization: "Bearer {{ tasks.login.results.token }}" }
        assert:
          - status == 200
          - body.orders any (it.id == tasks.create-order.results.orderId)

finally:
  - name: delete-order
    when: ["tasks.create-order.results.orderId != nil"]
    steps:
      - http:
          method: DELETE
          url: "{{ env.baseUrl }}/orders/{{ tasks.create-order.results.orderId }}"
          headers: { Authorization: "Bearer {{ tasks.login.results.token }}" }
        assert:
          - status in [204, 404]    # teardown that already happened must not fail the run

This page is examples/orders.yaml in the repository.

verodocs