diff options
Diffstat (limited to 'src/test_helpers/shared/with_temporary_path.rs')
-rw-r--r-- | src/test_helpers/shared/with_temporary_path.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/test_helpers/shared/with_temporary_path.rs b/src/test_helpers/shared/with_temporary_path.rs new file mode 100644 index 0000000..f0a7131 --- /dev/null +++ b/src/test_helpers/shared/with_temporary_path.rs @@ -0,0 +1,11 @@ +use std::path::Path; + +use tempfile::Builder; + +pub(crate) fn with_temporary_path<F>(callback: F) +where F: FnOnce(&Path) { + let temp_repository_directory = Builder::new().prefix("interactive-rebase-tool").tempdir().unwrap(); + let path = temp_repository_directory.path(); + callback(path); + temp_repository_directory.close().unwrap(); +} |