summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNora <nora.widdecke@tu-bs.de>2019-01-22 20:12:41 +0100
committerNora <nora.widdecke@tu-bs.de>2019-01-22 20:12:41 +0100
commit1b81055f77730672e0e2857bb727ac462284654d (patch)
tree2a9a2b906ce698560910a42f27977a2b528d3d04
parente7cbf6c69c1edbf97418e72a0f0ba8f1fea32b45 (diff)
copy: add test
-rw-r--r--src/actions/copy.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/actions/copy.rs b/src/actions/copy.rs
index d1bb5ca..00b2245 100644
--- a/src/actions/copy.rs
+++ b/src/actions/copy.rs
@@ -9,10 +9,6 @@ pub fn do_copy(_args: &[&str]) -> KhResult<()> {
let khline = input::default_input_khline()?;
let uid = &misc::make_new_uid();
- copy_internal(&khline, uid).map(|_| ())
-}
-
-fn copy_internal(khline: &KhLine, uid: &str) -> KhResult<KhLine> {
let cal = khline.to_cal()?;
let new_cal = cal.with_uid(uid)?.with_dtstamp_now();
@@ -20,7 +16,7 @@ fn copy_internal(khline: &KhLine, uid: &str) -> KhResult<KhLine> {
info!("Successfully wrote file: {}", new_cal.get_path().unwrap().display());
- Ok(KhLine::from(&new_cal))
+ Ok(())
}
@@ -31,16 +27,17 @@ mod tests {
use testutils::prepare_testdir;
use assert_fs::prelude::*;
use predicates::prelude::*;
+ use utils::stdioutils;
#[test]
fn copy_test() {
let testdir = prepare_testdir("testdir");
- let khline_from_file = "twodaysacrossbuckets.ics".parse::<KhLine>().unwrap();
- let uid = "my_new_uid";
- copy_internal(&khline_from_file, uid).unwrap();
+ stdioutils::test_stdin_write("twodaysacrossbuckets.ics");
- testdir.child(".khaleesi/cal/".to_string() + uid + ".ics").assert(predicate::path::exists());
- }
+ do_copy(&[]).unwrap();
+ let child = testdir.child(".khaleesi/cal/11111111-2222-3333-4444-444444444444@khaleesi.ics");
+ child.assert(predicate::path::exists());
+ }
}