pub struct ContainerGuardSetBuilder { /* private fields */ }Expand description
Builder for creating a ContainerGuardSet.
§Example
use docker_wrapper::testing::ContainerGuardSet;
use docker_wrapper::RedisTemplate;
let guards = ContainerGuardSet::new()
.with_network("test-network")
.add(RedisTemplate::new("redis-1"))
.add(RedisTemplate::new("redis-2"))
.start_all()
.await?;
// Access by name
assert!(guards.contains("redis-1"));Implementations§
Source§impl ContainerGuardSetBuilder
impl ContainerGuardSetBuilder
Sourcepub fn add<T: Template + 'static>(self, template: T) -> Self
pub fn add<T: Template + 'static>(self, template: T) -> Self
Add a template to the set.
The container name from the template’s config is used as the key for lookup.
Sourcepub fn with_network(self, network: impl Into<String>) -> Self
pub fn with_network(self, network: impl Into<String>) -> Self
Set a shared network for all containers.
The network will be created if it doesn’t exist (unless create_network(false) is called).
Sourcepub fn create_network(self, create: bool) -> Self
pub fn create_network(self, create: bool) -> Self
Set whether to create the network if it doesn’t exist (default: true).
Sourcepub fn remove_network_on_drop(self, remove: bool) -> Self
pub fn remove_network_on_drop(self, remove: bool) -> Self
Set whether to remove the network on drop (default: true when network is set).
Sourcepub fn keep_on_panic(self, keep: bool) -> Self
pub fn keep_on_panic(self, keep: bool) -> Self
Set whether to keep containers running if the test panics (default: false).
Sourcepub fn wait_for_ready(self, wait: bool) -> Self
pub fn wait_for_ready(self, wait: bool) -> Self
Set whether to wait for each container to be ready (default: true).
Sourcepub async fn start_all(self) -> Result<ContainerGuardSet, TemplateError>
pub async fn start_all(self) -> Result<ContainerGuardSet, TemplateError>
Start all containers and return a guard set.
Containers are started sequentially in the order they were added.
§Errors
Returns an error if any container fails to start. Containers that were successfully started before the failure will be cleaned up.