()
| 4 | |
| 5 | #[tokio::test] |
| 6 | async fn test_db_handler_basic() -> Result<(), Box<dyn std::error::Error>> { |
| 7 | let temp_dir = tempfile::tempdir()?; |
| 8 | let db_path = temp_dir.path().join("test_basic.db"); |
| 9 | let db_handler = Arc::new(DbHandler::new(db_path.to_str().unwrap())?); |
| 10 | |
| 11 | // Create a session |
| 12 | let session_id = Uuid::new_v4(); |
| 13 | db_handler.create_session_connection(session_id).await?; |
| 14 | |
| 15 | // Test basic operations |
| 16 | db_handler.execute_with_session("CREATE TABLE test_basic (id INTEGER PRIMARY KEY, name TEXT)", &session_id).await?; |
| 17 | db_handler.execute_with_session("INSERT INTO test_basic (name) VALUES ('test1')", &session_id).await?; |
| 18 | |
| 19 | let result = db_handler.query_with_session("SELECT * FROM test_basic", &session_id).await?; |
| 20 | assert_eq!(result.rows.len(), 1); |
| 21 | assert_eq!(result.columns, vec!["id", "name"]); |
| 22 | |
| 23 | // Clean up |
| 24 | db_handler.remove_session_connection(&session_id); |
| 25 | |
| 26 | Ok(()) |
| 27 | } |
| 28 | |
| 29 | #[tokio::test] |
| 30 | async fn test_db_handler_transactions() -> Result<(), Box<dyn std::error::Error>> { |
nothing calls this directly
no test coverage detected