From dedbf95f3e9b769dfb33b73e24c0675f42c828ce Mon Sep 17 00:00:00 2001 From: "Andrew Phillips (aider)" Date: Mon, 12 May 2025 13:33:50 -0300 Subject: [PATCH] fix: resolve variable scope and function argument issues in tests --- src/tests.rs | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/tests.rs b/src/tests.rs index 582e4b3..57b86a2 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -75,6 +75,10 @@ mod tests { // Set the data directory for this test let env = format!("KEEP_DIR={} cargo run --", data_dir.display()); + // Test content and tags + let input = "test content"; + let tag = "tag"; + // Create a command that pipes input to keep with the specified environment let cmd = format!("echo {} | {} {}", input, env, tag); let output = run_sh(cmd.as_str()); @@ -83,7 +87,7 @@ mod tests { "Command failed: {} RC={}", cmd, output.status - ); + ); }); } @@ -210,20 +214,7 @@ mod tests { fn test_delete_item() { with_temp_env(|data_dir| { // Create test items with the common environment setup - create_test_items(data_dir, |input, tag| { - // Set the data directory for this test - let env = format!("KEEP_DIR={} cargo run --", data_dir.display()); - - // Create a command that pipes input to keep with the specified environment - let cmd = format!("echo {} | {} {}", input, env, tag); - let output = run_sh(cmd.as_str()); - assert!( - output.status.success(), - "Command failed: {} RC={}", - cmd, - output.status - ); - }); + create_test_items(data_dir); let env = format!("KEEP_DIR={} cargo run --", data_dir.display());