fix: resolve variable scope and function argument issues in tests
This commit is contained in:
21
src/tests.rs
21
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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user