ContainerGuardSetBuilder

Struct ContainerGuardSetBuilder 

Source
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

Source

pub fn new() -> Self

Create a new builder.

Source

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.

Source

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).

Source

pub fn create_network(self, create: bool) -> Self

Set whether to create the network if it doesn’t exist (default: true).

Source

pub fn remove_network_on_drop(self, remove: bool) -> Self

Set whether to remove the network on drop (default: true when network is set).

Source

pub fn keep_on_panic(self, keep: bool) -> Self

Set whether to keep containers running if the test panics (default: false).

Source

pub fn wait_for_ready(self, wait: bool) -> Self

Set whether to wait for each container to be ready (default: true).

Source

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.

Trait Implementations§

Source§

impl Default for ContainerGuardSetBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more