1
0
Fork 0
mirror of https://github.com/containers/youki synced 2024-05-21 15:06:07 +02:00
youki/tests/integration_test/src/tests/lifecycle/state.rs
Yashodhan 80f1f36ae9
Refactor test dir structure (#2421)
* Move individual rust-oci-tests components in the tests dir

We can use several things from test_framework and even integration_test
for additional tests such as podman rootless and wasm tests

Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com>

* fix scripts and docs for the new dir structure

Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com>

---------

Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com>
2023-10-10 21:00:02 +09:00

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")),
}
}