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

Function test_current_user_basic

tests/session_functions_test.rs:6–24  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5#[tokio::test]
6async fn test_current_user_basic() {
7 // Create a temporary database
8 let temp_dir = tempfile::tempdir().unwrap();
9 let db_path = temp_dir.path().join("session_test.db");
10 let db_handler = Arc::new(DbHandler::new(db_path.to_str().unwrap()).unwrap());
11
12 // Create session
13 let session_id = Uuid::new_v4();
14 db_handler.create_session_connection(session_id).await.unwrap();
15
16 // Test current_user function
17 let result = db_handler.query_with_session("SELECT current_user", &session_id).await.unwrap();
18
19 assert_eq!(result.columns.len(), 1);
20 assert_eq!(result.rows.len(), 1);
21
22 let user = String::from_utf8(result.rows[0][0].as_ref().unwrap().clone()).unwrap();
23 assert_eq!(user, "postgres");
24}
25
26#[tokio::test]
27async fn test_current_user_with_parentheses() {

Callers

nothing calls this directly

Calls 3

query_with_sessionMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected