Testing
Testing
Section titled “Testing”Last updated: 2026-05-19 (96afca6)
- Unit: Rust
#[test]/#[tokio::test]inside crate source files - Integration:
finstack-rs/tests/integration/— real Postgres (Neon); two pools:finstack_app(RLS-enforced) andfinstack_worker(BYPASSRLS for seeds). Never mocked. - E2E: Playwright (planned)
Running integration tests
Section titled “Running integration tests”# Set both pool URLsexport DATABASE_URL_APP="postgres://finstack_app:<pw>@<host>/finstack"export DATABASE_URL_WORKER="postgres://finstack_worker:<pw>@<host>/finstack"
# All integration testscargo test --package finstack-integration-tests
# Specific suitecargo test --package finstack-integration-tests --test http_payment_lifecyclecargo test --package finstack-integration-tests --test admin_provisioncargo test --package finstack-integration-tests --test refund_ledgerCoverage (as of 2026-05-19)
Section titled “Coverage (as of 2026-05-19)”| Area | Unit | Integration |
|---|---|---|
| primitive-payment | ✓ (FSM, serde, service) | ✓ (create/capture/refund) |
| primitive-ledger | ✓ | ✓ (balance, reversing entry) |
| primitive-customer | ✓ | ✓ |
| primitive-fraud | ✓ | ✓ |
| primitive-receipt | ✓ | ✓ |
| primitive-tax | ✓ | ✓ |
| primitive-tip | ✓ | ✓ |
| primitive-split | ✓ | ✓ |
| api-rest HTTP (/v1/payments) | — | ✓ (7 tests, PR #343) |
| api-admin (provision, auth, keys) | ✓ (require_admin guard ×4, ProvisionOut serde ×1) | ✓ (admin.rs + admin_provision.rs) |
| finstack-auth | ✓ | — |
| finstack-observability | ✓ (PR #343) | — |
| finstack-events | ✓ | ✓ |
| svc-orchestration | ✓ (36 unit) | ✓ (orchestration.rs — service layer + executor E2E with wiremock, PR #346; orchestration_e2e.rs — 4-step multi-primitive DAG) |
| svc-payfac | ✓ (derive_status_changed_at ×5, serde round-trip ×1) | ✓ |
| svc-compliance | ✓ (derive_status_changed_at ×5, serde round-trip ×1) | ✓ |
| svc-workflow | ✓ | ✓ |
| primitive-analytics | ✓ (fact_from_event, PR #344) | ✓ (analytics.rs) |
| primitive-inventory | ✓ (validate_create_item, validate_adjust_stock, PR #344) | ✓ (inventory.rs) |
| primitive-loyalty | ✓ (validate_earn, validate_redeem, PR #345) | ✓ (loyalty.rs) |
| svc-composer | ✓ (TenantConfig::empty, UpdateTenantConfig, PR #344) | ✓ (composer.rs) |
| svc-database | — | ✓ (database.rs — provision ×2, scope rejection ×3, path-validation ×3) |
Seed pattern (CLAUDE.md)
Section titled “Seed pattern (CLAUDE.md)”Seeds that bypass service methods MUST use pool_worker() (BYPASSRLS).
Production-path queries MUST use pool() (RLS-enforced).
See tests/integration/src/lib.rs for fresh_tenant, mint_api_key, app_router.