From 8fbced879b44d65fcf0e59f6ffa3e6c6d4453d6c Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Wed, 27 May 2020 00:34:32 -0400 Subject: added test for tempfile creation --- src/ed.rs | 13 +++++++++++++ src/logging.rs | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/ed.rs b/src/ed.rs index 5c87133..b87b4a1 100644 --- a/src/ed.rs +++ b/src/ed.rs @@ -56,3 +56,16 @@ pub fn call(body: &str) -> String { error::helper(fs::remove_file(tmp_loc), "Couldn't remove temporary file"); body } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn tempfile() { + let name = create_tmp_file(); + assert!(name.is_ok()); + let name = name.unwrap(); + fs::remove_file(name).unwrap(); + } +} diff --git a/src/logging.rs b/src/logging.rs index d748117..88d9f80 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -21,6 +21,7 @@ fn init(path: &str) -> error::Result<()> { mod tests { use super::*; + use crate::user; use std::fs; #[test] @@ -36,4 +37,15 @@ mod tests { fs::remove_file("clinte_test.log").unwrap(); } + + #[test] + #[ignore] + fn checked_init_logs() { + checked_init(); + log::info!("CHECKED INIT TEST"); + + let path = format!("/tmp/clinte_{}.log", *user::NAME); + let logfile = fs::read_to_string(&path).unwrap(); + assert!(logfile.contains("CHECKED INIT TEST")); + } } -- cgit 1.4.1-2-gfad0