mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 05:52:19 +00:00
sqlite: constructor for testing store
This commit is contained in:
@@ -112,7 +112,7 @@ impl CalendarStore for SqliteCalendarStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_db_pool(db_url: &str, migrate: bool) -> anyhow::Result<Pool<Sqlite>>{
|
pub async fn create_db_pool(db_url: &str, migrate: bool) -> anyhow::Result<Pool<Sqlite>> {
|
||||||
let db = SqlitePool::connect_with(
|
let db = SqlitePool::connect_with(
|
||||||
SqliteConnectOptions::new()
|
SqliteConnectOptions::new()
|
||||||
.filename(db_url)
|
.filename(db_url)
|
||||||
@@ -124,4 +124,10 @@ pub async fn create_db_pool(db_url: &str, migrate: bool) -> anyhow::Result<Pool<
|
|||||||
sqlx::migrate!("./migrations").run(&db).await?;
|
sqlx::migrate!("./migrations").run(&db).await?;
|
||||||
}
|
}
|
||||||
Ok(db)
|
Ok(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn create_test_store() -> anyhow::Result<SqliteCalendarStore> {
|
||||||
|
let db = SqlitePool::connect("sqlite::memory:").await?;
|
||||||
|
sqlx::migrate!("./migrations").run(&db).await?;
|
||||||
|
Ok(SqliteCalendarStore::new(db))
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user