Skip to content

Commit 5031d58

Browse files
committed
feat: add ContainerGuard for RAII container lifecycle management
Implements #216. ContainerGuard provides automatic container lifecycle management for tests using the RAII pattern: - Builder pattern for configuration (remove_on_drop, stop_on_drop, keep_on_panic, capture_logs, reuse_if_running) - Automatic cleanup on drop (stop and/or remove containers) - Dynamic port mapping via host_port() - Log capture on test failures with keep_on_panic - Container reuse support for faster test iterations - Works with any Template implementation New testing feature flag enables the module. Requires template-redis as a dependency for the Template trait.
1 parent f0a68af commit 5031d58

4 files changed

Lines changed: 605 additions & 0 deletions

File tree

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ template-nginx = ["reqwest"]
5050
template-redis-sentinel = ["template-redis"]
5151
template-redis-stack = ["template-redis"]
5252

53+
# Testing utilities (requires at least one template feature)
54+
testing = ["template-redis"]
55+
5356
[dependencies]
5457
tokio = { version = "1.46", features = [
5558
"process",

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ pub mod error;
402402
pub mod platform;
403403
pub mod prerequisites;
404404
pub mod stream;
405+
405406
#[cfg(any(
406407
feature = "templates",
407408
feature = "template-redis",
@@ -464,6 +465,8 @@ pub mod stream;
464465
feature = "template-nginx"
465466
))]
466467
pub mod template;
468+
#[cfg(feature = "testing")]
469+
pub mod testing;
467470

468471
pub use stream::{OutputLine, StreamHandler, StreamResult, StreamableCommand};
469472

0 commit comments

Comments
 (0)