Un-hardcode a test filename in an integration test (fixes #61)

This commit is contained in:
Olivier Tilloy
2024-04-23 17:56:32 +02:00
parent 3a8eddfe2c
commit 3dc3fdf5cd
+7 -3
View File
@@ -26,22 +26,26 @@ fn unknown_param() -> Result<(), Box<dyn std::error::Error>> {
fn cannot_read_files() -> Result<(), Box<dyn std::error::Error>> {
let file = NamedTempFile::new()?;
let nofile = NamedTempFile::new()?;
let nopath = nofile.into_temp_path();
std::fs::remove_file(&nopath)?;
let mut cmd = Command::cargo_bin("diffutils")?;
cmd.arg("foo.txt").arg(file.path());
cmd.arg(&nopath).arg(file.path());
cmd.assert()
.code(predicate::eq(2))
.failure()
.stderr(predicate::str::starts_with("Failed to read from-file"));
let mut cmd = Command::cargo_bin("diffutils")?;
cmd.arg(file.path()).arg("foo.txt");
cmd.arg(file.path()).arg(&nopath);
cmd.assert()
.code(predicate::eq(2))
.failure()
.stderr(predicate::str::starts_with("Failed to read to-file"));
let mut cmd = Command::cargo_bin("diffutils")?;
cmd.arg("foo.txt").arg("foo.txt");
cmd.arg(&nopath).arg(&nopath);
cmd.assert()
.code(predicate::eq(2))
.failure()