From d72a71d3257f6e6ee260a20495cde318bf2f98ca Mon Sep 17 00:00:00 2001 From: "Andrew Phillips (aider)" Date: Mon, 12 May 2025 13:11:25 -0300 Subject: [PATCH] test: add create_test_items helper for common test environment setup --- src/tests.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/tests.rs b/src/tests.rs index b49ff77..48048ff 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -34,6 +34,25 @@ mod tests { dir.close().expect("Failed to remove temporary directory"); } + // Helper function to create test items with specific content and tags + fn create_test_items(dir: &Path, f: F) + where + F: FnOnce(&str, &str), + { + // Set the data directory for this test + let env = format!("KEEP_DIR={} cargo run --", dir.display()); + + // Create test items + let input_a = "test content A"; + let input_b = "test content B"; + + // Create first item with tag_a + f(input_a, "tag_a"); + + // Create second item with tag_b + f(input_b, "tag_b"); + } + // Helper function to check if a file exists in the data directory fn file_exists(data_dir: &Path, id: i64) -> bool { let path = data_dir.join(id.to_string());