Feat: Add test for finding content in file.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
use assert_cmd::prelude::*; // Add methods on commands
|
use assert_cmd::prelude::*; // Add methods on commands
|
||||||
|
use assert_fs::prelude::*;
|
||||||
use predicates::prelude::*; // Used for writing assertions
|
use predicates::prelude::*; // Used for writing assertions
|
||||||
use std::process::Command; // Run programs
|
use std::process::Command; // Run programs
|
||||||
|
|
||||||
@@ -13,3 +14,17 @@ fn file_doesnt_exist() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn find_content_in_file() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let file = assert_fs::NamedTempFile::new("sample.txt")?;
|
||||||
|
file.write_str("A test\nActual content\nMore content\nAnother test")?;
|
||||||
|
|
||||||
|
let mut cmd = Command::cargo_bin("grrs")?;
|
||||||
|
cmd.arg("test").arg(file.path());
|
||||||
|
cmd.assert()
|
||||||
|
.success()
|
||||||
|
.stdout(predicate::str::contains("A test\nAnother test"));
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user