aboutsummaryrefslogtreecommitdiffstats
path: root/crates/config/src/import.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/config/src/import.rs')
-rw-r--r--crates/config/src/import.rs27
1 files changed, 5 insertions, 22 deletions
diff --git a/crates/config/src/import.rs b/crates/config/src/import.rs
index a9ad603..04d396f 100644
--- a/crates/config/src/import.rs
+++ b/crates/config/src/import.rs
@@ -817,24 +817,13 @@ mod tests {
assert!(failing.fetch().is_err());
}
- /// A directory of a test's files, removed with it.
- struct Scratch(PathBuf);
+ use crate::testing::Scratch;
- impl Scratch {
- fn new(name: &str) -> Scratch {
- let dir =
- std::env::temp_dir().join(format!("config-import-{name}-{}", std::process::id()));
- let _ = std::fs::remove_dir_all(&dir);
- std::fs::create_dir_all(&dir).unwrap();
- Scratch(dir)
- }
-
- /// A file holding `content`: its name.
- fn file(&self, name: &str, content: &str) -> String {
- std::fs::write(self.0.join(name), content).unwrap();
- name.to_owned()
- }
+ trait Fetch {
+ fn fetch(&self, raw: &str) -> Result<String>;
+ }
+ impl Fetch for Scratch {
/// What a command-line value gives, read in this directory.
fn fetch(&self, raw: &str) -> Result<String> {
let Raw::Import(mut importer) = parse_argument(raw) else {
@@ -936,12 +925,6 @@ mod tests {
assert!(expand("a${cmd+raw:cat key}", Some(&scratch.0)).is_err());
}
- impl Drop for Scratch {
- fn drop(&mut self) {
- let _ = std::fs::remove_dir_all(&self.0);
- }
- }
-
#[test]
fn the_parts_of_what_an_importer_names() {
let text = |text: &str| Part::Text(text.to_owned());