From 43ebe607616da784d277cf27a79635a71ff6426c Mon Sep 17 00:00:00 2001 From: Brian Pearce Date: Tue, 10 Dec 2019 19:52:34 +0100 Subject: [PATCH] feat(Edit): The edit subcommand Creates easy access for editing project files. Closes #6 --- edit/tests/edit.rs | 56 --------------------------------------- load/tests/helpers/mod.rs | 1 + new/tests/new.rs | 3 ++- 3 files changed, 3 insertions(+), 57 deletions(-) delete mode 100644 edit/tests/edit.rs diff --git a/edit/tests/edit.rs b/edit/tests/edit.rs deleted file mode 100644 index 75906e4..0000000 --- a/edit/tests/edit.rs +++ /dev/null @@ -1,56 +0,0 @@ -//! The integration suite for inspecting sessions. - -extern crate common; -extern crate new; -extern crate rand; - -#[cfg(test)] -mod test { - mod new { - use common::args::Args; - use new; - use rand::random; - use std::fs; - use std::path::PathBuf; - - pub fn new(project: &str, project_root: &PathBuf) -> Result<(), String> { - let args = Args { - flag_debug: false, - flag_dryrun: false, - flag_d: true, - flag_v: false, - flag_f: false, - flag_p: Some(format!("{}", project_root.display())), - flag_t: None, - arg_project: project.to_string(), - cmd_new: false, - cmd_snapshot: false, - }; - - new::exec(args) - } - - fn setup(project_name: &str) -> (PathBuf, PathBuf) { - let project_file = format!("/tmp/muxed_{}/{}.yml", random::(), project_name); - let project_path = PathBuf::from(&project_file); - - let m = project_path.clone(); - let muxed_path = project_path.parent().unwrap(); - (m, muxed_path.to_path_buf()) - } - - fn cleanup(config_path: &PathBuf) { - let _ = fs::remove_file(config_path); - let _ = fs::remove_dir(config_path.parent().unwrap()); - } - - #[test] - fn creates_new_file_muxed() { - let project_name = format!("muxed_int_test_{}", random::()); - let (project_path, muxed_path) = setup(&project_name); - let _ = new(&project_name, &muxed_path); - assert!(&project_path.exists()); - cleanup(&project_path); - } - } -} diff --git a/load/tests/helpers/mod.rs b/load/tests/helpers/mod.rs index 784dba1..ccc6054 100644 --- a/load/tests/helpers/mod.rs +++ b/load/tests/helpers/mod.rs @@ -72,6 +72,7 @@ fn open_muxed(project: &str, project_root: &Path) -> Result<(), String> { flag_p: Some(format!("{}", project_root.display())), flag_t: None, arg_project: project.to_string(), + cmd_edit: false, cmd_new: false, cmd_snapshot: false, }; diff --git a/new/tests/new.rs b/new/tests/new.rs index 62f016f..29f88dc 100644 --- a/new/tests/new.rs +++ b/new/tests/new.rs @@ -22,7 +22,8 @@ mod test { flag_p: Some(format!("{}", project_root.display())), flag_t: None, arg_project: project.to_string(), - cmd_new: false, + cmd_edit: false, + cmd_new: true, cmd_snapshot: false, };