#[cfg(test)] mod tests { use crate::db; use crate::db::Meta; use crate::tests::common::test_helpers::{create_temp_db, create_test_item}; #[test] fn test_database_meta_operations() { // Create a temporary database let (_temp_dir, conn, _db_path) = create_temp_db(); // First insert an item to have a valid ID let item_id = create_test_item(&conn); // Create a test meta with the valid item ID let meta = Meta { id: item_id, name: "test_key".to_string(), value: "test_value".to_string(), }; // Try to insert meta let insert_result = db::query_upsert_meta(&conn, meta.clone()); assert!(insert_result.is_ok()); // Try to get meta for non-existent item let item = crate::db::Item { id: Some(999), // Non-existent item ts: chrono::Utc::now(), size: Some(0), compression: crate::compression_engine::CompressionType::Raw.to_string(), }; let metas = db::get_item_meta(&conn, &item); assert!(metas.is_ok()); assert_eq!(metas.unwrap().len(), 0); } }