Files
keep/src/tests/db/item_tests.rs
Andrew Phillips 67af475339 fix: resolve import errors in test modules and remove unused variables
Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
2025-08-14 17:11:27 -03:00

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);
}
}