pub struct FakeEngine { /* private fields */ }testing only.Expand description
An in-memory Docker: up creates a project with scripted services, down removes it, and
both raise the events Docker would. Clones share state, so a test
can hand one to the code under test and inspect another.
A project’s name is read from the name: line of the head compose.yaml in the directory
up is given, as Compose does for the files trestle renders. Its services default to a
single healthy app; script sets others.
Implementations§
Source§impl FakeEngine
impl FakeEngine
Sourcepub fn script(
&self,
project: &str,
services: impl IntoIterator<Item = (&'static str, Health)>,
)
pub fn script( &self, project: &str, services: impl IntoIterator<Item = (&'static str, Health)>, )
Give project these services, each reaching health once up.
Sourcepub fn fail_up(&self, project: &str)
pub fn fail_up(&self, project: &str)
Make the next up of project fail, as an unhealthy --wait does.
Make every call fail as if the daemon were down (or back up with false).
Sourcepub fn adopt(&self, project: &str)
pub fn adopt(&self, project: &str)
Add a project as if something else had started it (e.g. a runtime that since died).
Sourcepub fn add_network(&self, name: &str)
pub fn add_network(&self, name: &str)
Declare the network name, as the first project joining it would.
Sourcepub fn set_health(&self, project: &str, service: &str, health: Health)
pub fn set_health(&self, project: &str, service: &str, health: Health)
Change the health of service in project, raising a health event.
Trait Implementations§
Source§impl Clone for FakeEngine
impl Clone for FakeEngine
Source§impl ComposeEngine for FakeEngine
impl ComposeEngine for FakeEngine
Source§fn up<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
opts: &'life2 UpOptions,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn up<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
opts: &'life2 UpOptions,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
dir (docker compose up -d).Source§fn down<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
opts: &'life2 DownOptions,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn down<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
opts: &'life2 DownOptions,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
dir (docker compose down).Source§fn ls<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ProjectStatus>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ls<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ProjectStatus>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
docker compose ls --all).Source§fn ps<'life0, 'life1, 'async_trait>(
&'life0 self,
project: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ServiceStatus>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn ps<'life0, 'life1, 'async_trait>(
&'life0 self,
project: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ServiceStatus>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
project, running or stopped (docker compose ps --all).Source§fn logs<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
project: &'life1 str,
_opts: &'life2 LogOptions,
) -> Pin<Box<dyn Future<Output = Result<EngineStream<LogLine>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn logs<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
project: &'life1 str,
_opts: &'life2 LogOptions,
) -> Pin<Box<dyn Future<Output = Result<EngineStream<LogLine>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
project’s containers (docker compose logs --timestamps).Source§fn events<'life0, 'life1, 'async_trait>(
&'life0 self,
filter: &'life1 EventFilter,
) -> Pin<Box<dyn Future<Output = Result<EngineStream<EngineEvent>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn events<'life0, 'life1, 'async_trait>(
&'life0 self,
filter: &'life1 EventFilter,
) -> Pin<Box<dyn Future<Output = Result<EngineStream<EngineEvent>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
filter picks, from now on (docker events).Source§fn network_rm<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn network_rm<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
name; Ok(false) when it doesn’t exist or is still in use.