refactor: remove function arg from create_test_items and move logic to tests

This commit is contained in:
Andrew Phillips (aider)
2025-05-12 13:31:44 -03:00
parent c34d7ccf4d
commit e5b36779db

View File

@@ -35,10 +35,7 @@ mod tests {
}
// Helper function to create test items with specific content and tags
fn create_test_items<F>(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());