fix failing test

This commit is contained in:
2022-07-15 22:10:10 +02:00
parent fb538a36bb
commit 3222712de8

View File

@@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};
use std::{fmt::Display, iter::zip, process::Command, str::FromStr, string::ParseError, sync::Arc};
use serde::{Serialize, Deserialize};
#[derive(Debug, PartialEq)]
pub enum ToolbxError {
@@ -104,21 +104,14 @@ impl ToolbxContainer {
fn parse_status(output: &str) -> Result<PodmanInspectInfo, ToolbxError> {
let result: Result<PodmanInspectArray, _> = serde_json::from_str(output);
match result {
Ok(inspect_vec) => {
match inspect_vec.first() {
Some(info) => {
Ok(info.clone())
Ok(inspect_vec) => match inspect_vec.first() {
Some(info) => Ok(info.clone()),
None => Err(ToolbxError::JSONSerializationError(
"Inspect command returned empty vecotr.".to_string(),
)),
},
Err(e) => Err(ToolbxError::JSONSerializationError(e.to_string())),
}
None => {
Err(ToolbxError::JSONSerializationError("Inspect command returned empty vecotr.".to_string()))
}
}
}
Err(e) => {
Err(ToolbxError::JSONSerializationError(e.to_string()))
}
}
}
pub fn update_status(&mut self) -> Result<(), ToolbxError> {
@@ -228,15 +221,22 @@ fn test_inspect_parsing() {
#[test]
fn test_start_non_existing_containter() {
let name = "zy2lM6BdZoTnKHaVPkUJ".to_string();
let mut tbx = ToolbxContainer {
created: "".to_string(),
id: "".to_string(),
name: "zy2lM6BdZoTnKHaVPkUJ".to_string(),
name: name.clone(),
image: "".to_string(),
status: ToolbxStatus::Exited,
};
assert_eq!(Ok(()), tbx.start());
assert_eq!(
Err(ToolbxError::CommandUnsuccessfulError(format!(
"Error: no container with name or ID \"{}\" found: no such container\n",
name
))),
tbx.start()
);
}
pub fn run_cmd_toolbx_list_containers() -> String {