mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +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(
|
||||
SqliteConnectOptions::new()
|
||||
.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?;
|
||||
}
|
||||
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