From e5b36779dba6ad85e3effb5078f32c41b3c1985a Mon Sep 17 00:00:00 2001 From: "Andrew Phillips (aider)" Date: Mon, 12 May 2025 13:31:44 -0300 Subject: [PATCH] refactor: remove function arg from create_test_items and move logic to tests --- src/tests.rs | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/src/tests.rs b/src/tests.rs index 6727f05..582e4b3 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -35,10 +35,7 @@ mod tests { } // Helper function to create test items with specific content and tags - fn create_test_items(dir: &Path, _f: F) - where - F: FnOnce(&str, &str), - { + fn create_test_items(dir: &Path) { // Set the data directory for this test let env = format!("KEEP_DIR={} cargo run --", dir.display()); @@ -94,20 +91,7 @@ mod tests { fn test_get_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()); @@ -188,20 +172,7 @@ mod tests { fn test_list_items() { 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());