Expand description
In-memory ContainerRuntime and supporting helpers for tests.
See testkit::MockRuntime for the main type.
Test helpers for downstream crates and integration tests.
Provides MockRuntime, an in-memory crate::ContainerRuntime that
requires no Docker daemon. Use it to test lifecycle logic, control-plane
handlers, and any code that depends on crate::LifecycleManager without
involving real containers.
§Behaviour
- Every container transitions from
crate::ContainerStatus::Startingtocrate::ContainerStatus::Healthy30 ms afterstartreturns. - Calling
MockRuntime::fail_onconfigures one resource name as a failure target:startreturnscrate::RuntimeError::InvalidSpecfor that name and leaves the mock state unmodified. MockRuntimeis cheap to clone: every internal field is anArc<Mutex<_>>, so a test can hold an observer clone for introspection after the manager has consumed the original instance.
§Example
use lightshuttle_runtime::{LifecyclePlan, LifecycleManager};
use lightshuttle_runtime::testkit::MockRuntime;
use lightshuttle_manifest::Manifest;
let manifest = Manifest::parse(
"project:\n name: t\nresources:\n db:\n postgres:\n version: \"16\"\n"
)?;
let plan = LifecyclePlan::from_manifest(&manifest)?;
let mock = MockRuntime::new();
let (manager, _events) = LifecycleManager::new(plan, mock.clone());
manager.start_all().await?;
assert_eq!(mock.started_resources(), vec!["t_db"]);Structs§
- Mock
Runtime - In-memory
ContainerRuntimefor tests.