use assert_cmd::Command;
use assert_fs::prelude::FileWriteStr;
use predicates::prelude::predicate;
#[test]
fn file_doesnt_exist() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("basti")?;
cmd.arg("foobar").arg("-f test/file/doesnt/exist");
cmd.assert()
.failure()
.stderr(predicate::str::contains("could not read file"));
Ok(())
}
#[test]
fn validate_mt940() -> Result<(), Box<dyn std::error::Error>> {
let file = assert_fs::NamedTempFile::new("mt940-test.mt")?;
file.write_str("A test\nActual content\nMore content\nAnother test")?;
let mut cmd = Command::cargo_bin("basti")?;
cmd.arg("test").arg("-f").arg(file.path());
cmd.assert()
.success();
Ok(())
}