From 46f769deb889a187360e1f5ca3fe20faa4641204 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 3 Sep 2017 22:08:01 +0200 Subject: [PATCH] Add test for delete() --- bin/core/imag-store/src/delete.rs | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/bin/core/imag-store/src/delete.rs b/bin/core/imag-store/src/delete.rs index 1413de77..7b9e56ed 100644 --- a/bin/core/imag-store/src/delete.rs +++ b/bin/core/imag-store/src/delete.rs @@ -46,3 +46,38 @@ pub fn delete(rt: &Runtime) { .or_else(|| warn_exit("No subcommand 'delete'. Will exit now", 1)); } +#[cfg(test)] +mod tests { + use create::create; + use super::delete; + + use std::path::PathBuf; + + make_mock_app! { + app "imag-link"; + modulename mock; + version "0.4.0"; + with help "imag-link mocking app"; + } + use self::mock::generate_test_runtime; + use self::mock::reset_test_runtime; + + #[test] + fn test_create_simple() { + let test_name = "test_create_simple"; + let rt = generate_test_runtime(vec!["create", "-p", "test_create_simple"]).unwrap(); + + create(&rt); + + let rt = reset_test_runtime(vec!["delete", "--id", "test_create_simple"], rt).unwrap(); + + delete(&rt); + + let e = rt.store().get(PathBuf::from(test_name)); + assert!(e.is_ok()); + let e = e.unwrap(); + assert!(e.is_none()); + } + +} +