feat: get exit status
This commit is contained in:
parent
17510c4ac2
commit
b3f7cb943e
1 changed files with 11 additions and 1 deletions
|
@ -32,6 +32,15 @@ impl Docker {
|
|||
child.wait().unwrap();
|
||||
}
|
||||
|
||||
pub fn get_exit_status(name: &str) -> isize {
|
||||
let output = Command::new("docker")
|
||||
.args(["inspect", name, "--format={{.State.ExitCode}}"])
|
||||
.output()
|
||||
.expect("unable to exit status");
|
||||
let out = String::from_utf8(output.stdout).unwrap();
|
||||
let out = out.trim();
|
||||
out.parse::<isize>().unwrap()
|
||||
}
|
||||
pub fn get_logs(name: &str) -> String {
|
||||
let output = Command::new("docker")
|
||||
.args(["logs", name])
|
||||
|
@ -60,7 +69,7 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_docker() {
|
||||
fn test_docker_util() {
|
||||
Docker::version();
|
||||
let name = format!("test_sleep__{}", get_random(4));
|
||||
let mut env = HashMap::new();
|
||||
|
@ -79,6 +88,7 @@ mod tests {
|
|||
assert!(logs.contains("running"));
|
||||
assert!(logs.contains("FOO=BAR"));
|
||||
assert!(logs.contains("BAZ=BOO"));
|
||||
assert_eq!(Docker::get_exit_status(&name), 0);
|
||||
Docker::rm_container(&name, true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue