summaryrefslogtreecommitdiffstats
path: root/src/testutils.rs
diff options
context:
space:
mode:
authorNora <nora.widdecke@tu-bs.de>2019-02-04 22:50:33 +0100
committerNora <nora.widdecke@tu-bs.de>2019-02-04 22:50:51 +0100
commitd0cf0a35472b9d2905f94b95e8addbeec67d882e (patch)
treeb006a0e6d68d3c8f81f8be725cbf9745d6bf1be3 /src/testutils.rs
parent1b67e6f8b610a2bafd34aca70c5f7cbb63ca4231 (diff)
khline: when parsing from string, check if file actually exists
Diffstat (limited to 'src/testutils.rs')
-rw-r--r--src/testutils.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/testutils.rs b/src/testutils.rs
index 42fa765..7b78a96 100644
--- a/src/testutils.rs
+++ b/src/testutils.rs
@@ -1,6 +1,7 @@
use assert_fs::prelude::*;
use assert_fs::TempDir;
-use std::path::PathBuf;
+use assert_fs::fixture::{ChildPath, FixtureError};
+use std::path::{PathBuf,Path};
use std::fs;
use defaults;
@@ -21,3 +22,9 @@ pub fn prepare_testdir(template: &str) -> TempDir {
testdir.child(".khaleesi/").copy_from(path_to(template), &["*"]).unwrap();
testdir
}
+
+pub fn touch_testfile(testdir: &TempDir, relative_path: &Path) -> Result<ChildPath, FixtureError> {
+ let testfile = testdir.child(relative_path);
+ testfile.touch()?;
+ Ok(testfile)
+}