mirror of
https://github.com/containers/youki
synced 2024-05-10 01:26:14 +02:00
464344923f
* Name the test tools `contest` Signed-off-by: utam0k <k0ma@utam0k.jp> * Address the feedbacks Signed-off-by: utam0k <k0ma@utam0k.jp> * Fix a build error Signed-off-by: utam0k <k0ma@utam0k.jp> * Fix a workflow Signed-off-by: utam0k <k0ma@utam0k.jp> * Address the feedbacks Signed-off-by: utam0k <k0ma@utam0k.jp> --------- Signed-off-by: utam0k <k0ma@utam0k.jp>
24 lines
866 B
Rust
24 lines
866 B
Rust
use crate::utils::get_state;
|
|
use anyhow::{bail, Result};
|
|
use std::path::Path;
|
|
|
|
pub fn state(project_path: &Path, id: &str) -> Result<()> {
|
|
match get_state(id, project_path) {
|
|
Ok((stdout, stderr)) => {
|
|
if stderr.contains("Error") || stderr.contains("error") {
|
|
bail!("Error :\nstdout : {}\nstderr : {}", stdout, stderr)
|
|
} else {
|
|
// confirm that the status is stopped, as this is executed after the kill command
|
|
if !(stdout.contains(&format!(r#""id": "{id}""#))
|
|
&& stdout.contains(r#""status": "stopped""#))
|
|
{
|
|
bail!("Expected state stopped, got : {}", stdout)
|
|
} else {
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
Err(e) => Err(e.context("failed to get container state")),
|
|
}
|
|
}
|