feat: create common test helpers to reduce duplication across test modules
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -1,26 +1,16 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use tempfile::TempDir;
|
||||
use crate::tests::common::test_helpers::{create_temp_db, create_test_item};
|
||||
use crate::db;
|
||||
use crate::db::Meta;
|
||||
|
||||
#[test]
|
||||
fn test_database_meta_operations() {
|
||||
// Create a temporary directory for the database
|
||||
let temp_dir = TempDir::new().expect("Failed to create temp directory");
|
||||
let db_path = temp_dir.path().join("test_meta.db");
|
||||
|
||||
// Open the database
|
||||
let conn = db::open(db_path).expect("Failed to open database");
|
||||
// Create a temporary database
|
||||
let (_temp_dir, conn, _db_path) = create_temp_db();
|
||||
|
||||
// First insert an item to have a valid ID
|
||||
let item = crate::db::Item {
|
||||
id: None,
|
||||
ts: chrono::Utc::now(),
|
||||
size: Some(100),
|
||||
compression: crate::compression_engine::CompressionType::None.to_string(),
|
||||
};
|
||||
let item_id = db::insert_item(&conn, item).expect("Failed to insert item");
|
||||
let item_id = create_test_item(&conn);
|
||||
|
||||
// Create a test meta with the valid item ID
|
||||
let meta = Meta {
|
||||
|
||||
Reference in New Issue
Block a user