From 2e1a8f0ae948fc1b69d735263e831c08fe5f16ed Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Wed, 28 Oct 2020 08:10:46 -0600 Subject: [PATCH] agent: Improve unit test coverage for src/sandbox.rs Improve unit test coverage for src/sandbox.rs fixes #293 Signed-off-by: Julio Montes --- src/agent/src/sandbox.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/agent/src/sandbox.rs b/src/agent/src/sandbox.rs index af8c82c44d..b4eadbf679 100644 --- a/src/agent/src/sandbox.rs +++ b/src/agent/src/sandbox.rs @@ -707,4 +707,31 @@ mod tests { assert!(s.hooks.as_ref().unwrap().poststart.is_empty()); assert!(s.hooks.as_ref().unwrap().poststop.is_empty()); } + + #[test] + pub fn test_sandbox_is_running() { + let logger = slog::Logger::root(slog::Discard, o!()); + let mut s = Sandbox::new(&logger).unwrap(); + s.running = true; + assert!(s.is_running()); + s.running = false; + assert!(!s.is_running()); + } + + #[test] + fn test_sandbox_set_hostname() { + let logger = slog::Logger::root(slog::Discard, o!()); + let mut s = Sandbox::new(&logger).unwrap(); + let hostname = "abc123"; + s.set_hostname(hostname.to_string()); + assert_eq!(s.hostname, hostname); + } + + #[test] + fn test_sandbox_set_destroy() { + let logger = slog::Logger::root(slog::Discard, o!()); + let mut s = Sandbox::new(&logger).unwrap(); + let ret = s.destroy(); + assert!(ret.is_ok()); + } }