Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

rtf-orchestrator

This page documents how tests in the rtf-orchestrator crate are organized and implemented. The crate uses two test styles:

See Run rtf-orchestrator tests for a step-by-step guide to running each category locally.

Categories

CategoryLocationRequires
Unit testssrc/ (#[cfg(test)] mod tests blocks)Nothing
DB testssrc/ (gated by db_tests feature)PostgreSQL via make db-up
Integration teststests/suite.rs (gated by k8s_tests feature)Full tilt stack

Running cargo test from the workspace root skips all stack-dependent tests. They must be run explicitly via make.

Unit test organization

Unit tests follow the Module → Function → Test class → Test case hierarchy from the unit test style:

#![allow(unused)]
fn main() {
// Without simple_test_case
module::path::tests::function_test_case

// With simple_test_case
module::path::tests::function_test_class::test_case
}

Integration test organization

Integration tests follow the Endpoint → Scenario naming described in the HTTP API integration test style:

#![allow(unused)]
fn main() {
endpoint_scenario
}

For example: trigger_valid_test_plan_returns_200.

Feature flag annotation

Stack-dependent tests must always carry this annotation to prevent the standard test run from failing without a stack:

#![allow(unused)]
fn main() {
#[cfg_attr(not(feature = "db_tests"), ignore)]    // for DB tests
#[cfg_attr(not(feature = "k8s_tests"), ignore)]   // for integration tests
}

Do not remove these annotations from existing tests.

Testing infrastructure

Integration tests use the following tools:

  • TestHelper — Defined in tests/common/mod.rs. Wraps reqwest::Client and provides convenience methods for calling server endpoints
  • tokio — #[tokio::test] for async test functions
  • reqwest — HTTP client used inside TestHelper
  • assert_fs — Temporary filesystem utilities; uses CARGO_TARGET_TMPDIR rather than /tmp to avoid macOS symlink issues with Docker volume mounts
  • simple_test_case — Parameterized testing with #[test_case] for multiple input variations

TestHelper API

#![allow(unused)]
fn main() {
pub struct TestHelper {
    client: Client,
}
}
MethodPurpose
prepare_orchestrator_payloadPrepares a TriggerPayload from a test plan directory
json_get / json_postTyped helpers that deserialize JSON responses into the expected type
get / postRaw helpers returning Response for status-code assertions

Shared logic between tests should be added as further methods on TestHelper.

Make targets

TargetDescription
make db-up / make db-downStart/stop the lightweight DB-only test stack
make db-testsRun DB-gated tests against the running DB stack
make cluster-setup && make cluster-up / make cluster-teardownStart/stop the full stack
make integration-testsRun tests/suite.rs against the running full stack
make ci-testsFull CI flow: stack up → wait → test → stack down