From c79294e0bdd3f045e2de4215f71db262c6e94848 Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Thu, 15 Aug 2019 11:39:58 -0500 Subject: basic test now includes relative path --- tests/tests.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'tests/tests.rs') diff --git a/tests/tests.rs b/tests/tests.rs index efdb909..2a7b6e8 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -5,10 +5,11 @@ mod tests { use rsycle::main::{build_path, empty, list, restore, rsycle}; use std::fs; use std::path::{Component, PathBuf}; + use std::ffi::OsStr; - fn get_rsyclebin() -> PathBuf { + fn gen_rsyclebin(dir_name: &str) -> PathBuf { let mut rsyclebin = dirs::home_dir().unwrap(); - rsyclebin.push(".test_rsyclebin"); + rsyclebin.push(dir_name); if !rsyclebin.exists() { fs::create_dir(&rsyclebin).unwrap(); } @@ -16,11 +17,12 @@ mod tests { } #[test] - fn test_rsycle() { - let rsyclebin = get_rsyclebin(); - - let filename = "test_file".as_ref(); + fn test_basics() { + test_rsycle("test_file".as_ref(), gen_rsyclebin(".test_rsyclebin")); + test_rsycle("../test_file_relative".as_ref(), gen_rsyclebin(".test_rsyclebin_relative")); + } + fn test_rsycle(filename: &OsStr, rsyclebin: PathBuf) { let mut test_path: PathBuf = [Component::CurDir, Component::Normal(filename)] .iter() .collect(); -- cgit v1.2.3