From 41a2027624d37eff1ba1ad95ff6447bc4590645a Mon Sep 17 00:00:00 2001 From: Ian Rettig Date: Mon, 9 Jun 2025 13:39:41 -0400 Subject: [PATCH] Feat: Add test for finding content in file. --- tests/cli.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/cli.rs b/tests/cli.rs index 69d71bf..aa44d27 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -1,4 +1,5 @@ use assert_cmd::prelude::*; // Add methods on commands +use assert_fs::prelude::*; use predicates::prelude::*; // Used for writing assertions use std::process::Command; // Run programs @@ -13,3 +14,17 @@ fn file_doesnt_exist() -> Result<(), Box> { Ok(()) } + +#[test] +fn find_content_in_file() -> Result<(), Box> { + 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(()) +}