Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
36 lines
1.1 KiB
Rust
36 lines
1.1 KiB
Rust
#[cfg(test)]
|
|
mod tests {
|
|
use tempfile::TempDir;
|
|
use crate::db;
|
|
|
|
#[test]
|
|
fn test_database_connection() {
|
|
// 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.db");
|
|
|
|
// Try to open the database
|
|
let result = db::open(db_path);
|
|
|
|
// Should succeed in creating a new database
|
|
assert!(result.is_ok());
|
|
}
|
|
|
|
#[test]
|
|
fn test_database_item_queries() {
|
|
// 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_items.db");
|
|
|
|
// Open the database
|
|
let conn = db::open(db_path).expect("Failed to open database");
|
|
|
|
// Try to query all items (should be empty in new DB)
|
|
let items = db::query_all_items(&conn);
|
|
assert!(items.is_ok());
|
|
|
|
// Should start with no items
|
|
assert_eq!(items.unwrap().len(), 0);
|
|
}
|
|
}
|