Creates a raw libsql database in a temp directory. Returns (Connection, Database, TempDir) — all three must stay alive.
()
| 15 | /// Creates a raw libsql database in a temp directory. |
| 16 | /// Returns (Connection, Database, TempDir) — all three must stay alive. |
| 17 | async fn create_raw_db() -> (Connection, LibsqlDatabase, TempDir) { |
| 18 | let dir = TempDir::new().expect("failed to create temp dir"); |
| 19 | let db_path = dir.path().join("test.db"); |
| 20 | let db = Builder::new_local(&db_path) |
| 21 | .build() |
| 22 | .await |
| 23 | .expect("failed to build libsql database"); |
| 24 | let conn = db.connect().expect("failed to connect"); |
| 25 | conn.execute_batch( |
| 26 | "PRAGMA auto_vacuum = INCREMENTAL; |
| 27 | PRAGMA journal_mode = WAL; |
| 28 | PRAGMA foreign_keys = ON; |
| 29 | PRAGMA busy_timeout = 5000;", |
| 30 | ) |
| 31 | .await |
| 32 | .expect("failed to apply pragmas"); |
| 33 | (conn, db, dir) |
| 34 | } |
| 35 | |
| 36 | /// Opens an existing database file raw, applying the per-connection pragmas |
| 37 | /// tests rely on (foreign keys for cascade assertions, busy timeout). |
no test coverage detected