MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / open_test_db_connection

Function open_test_db_connection

tests/mcp_suite/mcp_handler_test.rs:62–88  ·  view source on GitHub ↗
(db_path: &Path)

Source from the content-addressed store, hash-verified

60}
61
62async fn open_test_db_connection(db_path: &Path) -> TestDbConnection {
63 let db = libsql::Builder::new_local(db_path).build().await.unwrap();
64 let conn = db.connect().unwrap();
65 // Mirror the pragma choices of src/db/connection.rs, including the
66 // CI-only TRACEDECAY_SQLITE_UNSAFE_FAST=1 escape hatch, so this helper
67 // never fights the journal mode the product code selected.
68 let unsafe_fast = std::env::var(tracedecay::db::SQLITE_UNSAFE_FAST_ENV).as_deref() == Ok("1");
69 let (journal_mode, synchronous) = if unsafe_fast {
70 ("MEMORY", "OFF")
71 } else if cfg!(windows) {
72 ("DELETE", "FULL")
73 } else {
74 ("WAL", "NORMAL")
75 };
76 if cfg!(windows) {
77 conn.execute_batch("PRAGMA mmap_size = 0;").await.unwrap();
78 }
79 conn.execute_batch(&format!(
80 "PRAGMA journal_mode = {journal_mode};
81 PRAGMA busy_timeout = 5000;
82 PRAGMA synchronous = {synchronous};
83 PRAGMA foreign_keys = ON;"
84 ))
85 .await
86 .unwrap();
87 TestDbConnection { _db: db, conn }
88}
89
90async fn handle_tool_call(
91 cg: &TraceDecay,

Calls 2

buildMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected