Skip to main content

Module testkit

Module testkit 

Source
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

§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§

MockRuntime
In-memory ContainerRuntime for tests.