refactor: remove function arg from create_test_items and move logic to tests
This commit is contained in:
35
src/tests.rs
35
src/tests.rs
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user