From f8ba0c36009a85c3ffce50c58fd0f51da2e8d0b0 Mon Sep 17 00:00:00 2001 From: Lennart <18233294+lennart-k@users.noreply.github.com> Date: Mon, 26 Feb 2024 16:30:08 +0100 Subject: [PATCH] sqlite: constructor for testing store --- crates/store/src/sqlite_store.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/store/src/sqlite_store.rs b/crates/store/src/sqlite_store.rs index 354b1aa..e2a51c7 100644 --- a/crates/store/src/sqlite_store.rs +++ b/crates/store/src/sqlite_store.rs @@ -112,7 +112,7 @@ impl CalendarStore for SqliteCalendarStore { } } -pub async fn create_db_pool(db_url: &str, migrate: bool) -> anyhow::Result>{ +pub async fn create_db_pool(db_url: &str, migrate: bool) -> anyhow::Result> { let db = SqlitePool::connect_with( SqliteConnectOptions::new() .filename(db_url) @@ -124,4 +124,10 @@ pub async fn create_db_pool(db_url: &str, migrate: bool) -> anyhow::Result anyhow::Result { + let db = SqlitePool::connect("sqlite::memory:").await?; + sqlx::migrate!("./migrations").run(&db).await?; + Ok(SqliteCalendarStore::new(db)) +}