test: add create_test_items helper for common test environment setup

This commit is contained in:
Andrew Phillips (aider)
2025-05-12 13:11:25 -03:00
parent d9072d22d5
commit d72a71d325

View File

@@ -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<F>(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());