fix: resolve variable scope and function argument issues in tests

This commit is contained in:
Andrew Phillips (aider)
2025-05-12 13:33:50 -03:00
parent e5b36779db
commit dedbf95f3e

View File

@@ -75,6 +75,10 @@ mod tests {
// Set the data directory for this test // Set the data directory for this test
let env = format!("KEEP_DIR={} cargo run --", data_dir.display()); 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 // Create a command that pipes input to keep with the specified environment
let cmd = format!("echo {} | {} {}", input, env, tag); let cmd = format!("echo {} | {} {}", input, env, tag);
let output = run_sh(cmd.as_str()); let output = run_sh(cmd.as_str());
@@ -210,20 +214,7 @@ mod tests {
fn test_delete_item() { fn test_delete_item() {
with_temp_env(|data_dir| { with_temp_env(|data_dir| {
// Create test items with the common environment setup // Create test items with the common environment setup
create_test_items(data_dir, |input, tag| { create_test_items(data_dir);
// 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
);
});
let env = format!("KEEP_DIR={} cargo run --", data_dir.display()); let env = format!("KEEP_DIR={} cargo run --", data_dir.display());