Skip to content

Commit 0304391

Browse files
Create test files in temporary directory
1 parent 476e69e commit 0304391

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

tests/integration.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ use diffutilslib::assert_diff_eq;
88
use predicates::prelude::*;
99
use std::fs::File;
1010
use std::io::Write;
11-
use std::path::PathBuf;
12-
use tempfile::NamedTempFile;
11+
use tempfile::{tempdir, NamedTempFile};
1312

1413
// Integration tests for the diffutils command
1514

@@ -238,14 +237,13 @@ fn read_from_stdin() -> Result<(), Box<dyn std::error::Error>> {
238237
}
239238

240239
#[test]
241-
fn read_from_directory() -> Result<(), Box<dyn std::error::Error>> {
242-
let target = PathBuf::from("target/integration");
243-
let _ = std::fs::create_dir(&target);
240+
fn compare_file_to_directory() -> Result<(), Box<dyn std::error::Error>> {
241+
let tmp_dir = tempdir()?;
244242

245-
let directory = target.join("d");
243+
let directory = tmp_dir.path().join("d");
246244
let _ = std::fs::create_dir(&directory);
247245

248-
let a_path = target.join("a");
246+
let a_path = tmp_dir.path().join("a");
249247
let mut a = File::create(&a_path).unwrap();
250248
a.write_all(b"a\n").unwrap();
251249

0 commit comments

Comments
 (0)