Test support utilities for rust-framework-workspace - live-Postgres harness via env-var connection (Docker retired, sprint 0.38)
| Tier | foundation |
| Role | unclassified (baselined) |
| Path | crates/foundation/test-support |
| Edition | 2021 |
| Targets | foundation_test_support, calendar_contracts |
| Public items | 0 across 0 modules |
| Tests | 24 |
What it is for
Test support utilities for rust-framework-workspace.
Provides a Testcontainers-based PostgreSQL harness that:
- Spins up a fresh Postgres container per test suite
- Applies all migrations in the correct dependency order
- Exposes a connection pool for tests
- Cleans up automatically when dropped
# Usage
use foundation_test_support::TestDb;
#tokio::test
async fn test_something() {
let db = TestDb::new().await.expect("Failed to start test database");
let pool = db.pool();
// Your test code here using pool
}
# Migration Order
Migrations are applied in a strict topological order based on dependencies: 1. Foundation layer (basemodels first) 2. Identity layer (parties, then auth, rbac, identifiers) 3. Domain layer (encounters, catalog, billing, etc.) 4. Content layer (documents, notes, cms) 5. Infrastructure layer (communication)
# CI Considerations
- Container reuse is disabled for determinism
- Postgres 16 is used (pinned version)
- Timeouts are set for container startup (60s) and migrations (120s)
Capabilities
No public items.
How to use it
From this crate's own rustdoc:
use foundation_test_support::TestDb;
#[tokio::test]
async fn test_something() {
let db = TestDb::new().await.expect("Failed to start test database");
let pool = db.pool();
// Your test code here using pool
}
Module structure
No public modules: the crate root is its whole surface.
Public surface
No public items.
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
MigrationOrder | migrations::MigrationOrder |
PgPool | sqlx::PgPool |
repo_root_from | repo_root::repo_root_from |
{TestDb,TestDbError} | harness::{TestDb,TestDbError} |
{assert_all_escapes_refused,assert_command_confined,assert_command_confined_with,escape_candidates,BoundaryWatch,EscapeCandidate,Violation,} | boundary::{assert_all_escapes_refused,assert_command_confined,assert_command_confined_with,escape_candidates,BoundaryWatch,EscapeCandidate,Violation,} |
Boundary
Depends on no other workspace tier.
Shares tier foundation with 27 other crates: foundation-audit-log, foundation-basemodels, foundation-bounded-io, foundation-conversation-closure, foundation-crypto-sign, foundation-decisioning, foundation-encounter-vocabulary, foundation-fs-metadata, … (27 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | foundation |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/foundation/test-support |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | no | always |
tempfile | ^3 | — | no | always |
thiserror | ^2 | — | no | always |
tokio | ^1 | full | no | always |
tracing | ^0.1 | — | no | always |
Development, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `content-calendar` | content | no | always |
| `content-calendar-recurrence` | content | no | always |
| `identity-parties` | identity | no | always |
| `operations-planning` | operations | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
chrono | ^0.4 | serde | no | always |
tokio-test | ^0.4 | — | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Build. None.
Depended on by. 3 workspace crates.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_tools_corpus["tools-corpus"] -->|uses| SELF n_tools_session_error_audit["tools-session-error-audit"] -->|uses| SELF n_tools_untracked_intake["tools-untracked-intake"] -->|uses| SELF SELF["foundation-test-support"] SELF -->|development| n_content_calendar["content-calendar"] SELF -->|development| n_content_calendar_recurrence["content-calendar-recurrence"] SELF -->|development| n_identity_parties["identity-parties"] SELF -->|development| n_operations_planning["operations-planning"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | foundation_test_support | `src/lib.rs` |
| test | calendar_contracts | `tests/calendar_contracts.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | yes |
| database access | yes |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | yes |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
| Variable | Read in |
|---|---|
DATABASE_URL | src/harness.rs |
TEST_DATABASE_URL | src/harness.rs |
Related capabilities
3 workspace crates depend on this one: tools-corpus, tools-session-error-audit, tools-untracked-intake.
Verification
| Kind | Count |
|---|---|
| Unit tests | 19 |
| Integration tests | 5 |
| Examples | 0 |
| Doctests | 1 |
What the tests establish, by name:
contract_full_stack_scope_recurrence_planning—tests/calendar_contracts.rscontract_recurrence_plus_planning_per_occurrence_dues—tests/calendar_contracts.rscontract_scope_plus_planning_cascade_delete—tests/calendar_contracts.rscontract_scope_plus_recurrence_share_encounter—tests/calendar_contracts.rscontract_skipped_occurrence_planning_items_still_exist—tests/calendar_contracts.rsassert_all_escapes_refused_panics_when_one_candidate_is_wrongly_accepted—src/boundary.rsassert_all_escapes_refused_passes_when_every_candidate_is_refused—src/boundary.rsassert_command_confined_is_generic_over_any_external_process—src/boundary.rsassert_command_confined_passes_a_well_behaved_external_process—src/boundary.rscandidates_are_generated_fresh_from_whatever_root_is_passed_not_copy_pasted—src/boundary.rsdotdot_candidate_stays_inside_a_writable_ancestor—src/boundary.rsevery_candidate_actually_resolves_outside_root—src/boundary.rswatch_catches_a_write_inside_the_pre_existing_symlink_target—src/boundary.rswatch_catches_a_write_that_lands_exactly_on_a_dotdot_escape_candidate—src/boundary.rswatch_reports_clean_when_the_action_writes_only_inside_root—src/boundary.rstest_find_crates_root—src/harness.rstest_migration_order_directories_all—src/migrations.rstest_migration_order_directories_for_identifiers—src/migrations.rstest_migration_order_directories_for_parties—src/migrations.rstest_verification_only_detection—src/migrations.rsa_copied_tree_with_no_git_yields_none—src/repo_root.rsa_git_repo_with_a_cargo_toml_is_this_workspace—src/repo_root.rsa_git_repo_without_a_cargo_toml_is_not_this_workspace—src/repo_root.rsthe_nearest_qualifying_ancestor_wins—src/repo_root.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 0 | 0 |
Public modules with a //! block | 0 | 0 |
Metrics
| Metric | Value |
|---|---|
| Rust source files | 5 |
| Source lines | 1685 |
| Code lines | 963 |
| Public API items | 0 |
| Public modules | 0 |
| Tests | 24 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 5 |
| Workspace reverse dependencies | 3 |
pie showData
title Rust source composition
"Code" : 963
"Blank or comment" : 722
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.