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
|
// Helper function to create test items with specific content and tags
|
||||||
fn create_test_items<F>(dir: &Path, _f: F)
|
fn create_test_items(dir: &Path) {
|
||||||
where
|
|
||||||
F: FnOnce(&str, &str),
|
|
||||||
{
|
|
||||||
// Set the data directory for this test
|
// Set the data directory for this test
|
||||||
let env = format!("KEEP_DIR={} cargo run --", dir.display());
|
let env = format!("KEEP_DIR={} cargo run --", dir.display());
|
||||||
|
|
||||||
@@ -94,20 +91,7 @@ mod tests {
|
|||||||
fn test_get_item() {
|
fn test_get_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());
|
||||||
|
|
||||||
@@ -188,20 +172,7 @@ mod tests {
|
|||||||
fn test_list_items() {
|
fn test_list_items() {
|
||||||
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());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user