From 8b07bc2c805660b143558adf7821b48391667307 Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Fri, 28 Aug 2020 14:44:43 -0500 Subject: [PATCH] agent: fix unit tests - remove rustjail::errors Fix unit tests and use `anyhow::Error`. Signed-off-by: Julio Montes --- src/agent/src/config.rs | 3 ++- src/agent/src/main.rs | 4 ++-- src/agent/src/sandbox.rs | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/agent/src/config.rs b/src/agent/src/config.rs index 10c151eeaa..1b854fe743 100644 --- a/src/agent/src/config.rs +++ b/src/agent/src/config.rs @@ -203,6 +203,7 @@ fn get_container_pipe_size(param: &str) -> Result { #[cfg(test)] mod tests { use super::*; + use anyhow::Error; use std::fs::File; use std::io::Write; use std::time; @@ -223,7 +224,7 @@ mod tests { // helper function to make errors less crazy-long fn make_err(desc: &str) -> Error { - anyhow!(desc) + anyhow!(desc.to_string()) } // Parameters: diff --git a/src/agent/src/main.rs b/src/agent/src/main.rs index 3a4c44514d..01fd71f7b7 100644 --- a/src/agent/src/main.rs +++ b/src/agent/src/main.rs @@ -470,7 +470,7 @@ mod tests { assert!(result.is_err()); assert_eq!( result.unwrap_err().to_string(), - "Error Code: 'no shell found to launch debug console'" + "no shell found to launch debug console" ); } @@ -496,7 +496,7 @@ mod tests { assert!(result.is_err()); assert_eq!( result.unwrap_err().to_string(), - "Error Code: 'no shell found to launch debug console'" + "no shell found to launch debug console" ); } } diff --git a/src/agent/src/sandbox.rs b/src/agent/src/sandbox.rs index 964c1d6861..c34c3cdd74 100644 --- a/src/agent/src/sandbox.rs +++ b/src/agent/src/sandbox.rs @@ -350,6 +350,7 @@ mod tests { //use rustjail::Error; use super::Sandbox; use crate::{mount::BareMount, skip_if_not_root}; + use anyhow::Error; use nix::mount::MsFlags; use oci::{Linux, Root, Spec}; use rustjail::container::LinuxContainer; @@ -359,7 +360,7 @@ mod tests { use std::os::unix::fs::PermissionsExt; use tempfile::Builder; - fn bind_mount(src: &str, dst: &str, logger: &Logger) -> Result<(), rustjail::errors::Error> { + fn bind_mount(src: &str, dst: &str, logger: &Logger) -> Result<(), Error> { let baremount = BareMount::new(src, dst, "bind", MsFlags::MS_BIND, "", &logger); baremount.mount() }