MCPcopy Create free account
hub / github.com/erans/pgsqlite / test_db_handler_basic

Function test_db_handler_basic

tests/connection_pool_test.rs:6–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5#[tokio::test]
6async 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]
30async fn test_db_handler_transactions() -> Result<(), Box<dyn std::error::Error>> {

Callers

nothing calls this directly

Calls 4

query_with_sessionMethod · 0.80
execute_with_sessionMethod · 0.45

Tested by

no test coverage detected