mod info;
mod list;
mod multipass;
#[cfg(test)]
mod tests {
use crate::list;
use crate::multipass::Instance;
use std::any::{Any, TypeId};
use std::process::Command;
#[test]
fn list() {
let result = list::list();
match result {
Ok(instances) => {
let output = Command::new("sh")
.arg("-c")
.arg("multipass list")
.output()
.expect("failed to execute process");
let stdout = String::from_utf8(output.stdout).unwrap();
assert_eq!(instances.type_id(), TypeId::of::<Vec<Instance>>());
assert_eq!(
instances.len(),
stdout
.split("\n")
.filter(|line| *line != "No instances found."
&& (*line)
.split(" ")
.filter(|column| *column != "")
.collect::<Vec<_>>()
.as_slice()
!= ["Name", "State", "IPv4", "Image"]
&& *line != "")
.collect::<Vec<_>>()
.len()
);
}
Err(err) => {
assert_eq!(err, "No instances found.");
}
}
}
}