Janky fix for sqlite tests

This commit is contained in:
Lennart
2025-01-15 16:46:16 +01:00
parent c01f542e04
commit 618ed3b327
2 changed files with 11 additions and 4 deletions

View File

@@ -1,14 +1,17 @@
use rstest::rstest; use rstest::rstest;
use rstest_reuse::{self, apply, template}; use rstest_reuse::{self, apply, template};
use rustical_store::{CalendarObject, CalendarStore}; use rustical_store::{CalendarObject, CalendarStore};
use rustical_store_sqlite::create_test_store; use rustical_store_sqlite::{calendar_store::SqliteCalendarStore, create_test_db};
const TIMEZONE: &str = include_str!("examples/timezone.ics"); const TIMEZONE: &str = include_str!("examples/timezone.ics");
const EVENT: &str = include_str!("examples/event.ics"); const EVENT: &str = include_str!("examples/event.ics");
#[template] #[template]
#[rstest] #[rstest]
#[case::sqlite(async {create_test_store().await.unwrap() })] #[case::sqlite(async {
let (send, _recv) = tokio::sync::mpsc::channel(100);
SqliteCalendarStore::new(create_test_db().await.unwrap(), send)
})]
async fn cal_store<CS: CalendarStore>( async fn cal_store<CS: CalendarStore>(
#[future(awt)] #[future(awt)]
#[case] #[case]

View File

@@ -43,8 +43,12 @@ pub async fn create_db_pool(db_url: &str, migrate: bool) -> Result<Pool<Sqlite>,
Ok(db) Ok(db)
} }
pub async fn create_test_store() -> Result<SqliteStore, sqlx::Error> { pub async fn create_test_db() -> Result<SqlitePool, sqlx::Error> {
let db = SqlitePool::connect("sqlite::memory:").await?; let db = SqlitePool::connect("sqlite::memory:").await?;
sqlx::migrate!("./migrations").run(&db).await?; sqlx::migrate!("./migrations").run(&db).await?;
Ok(SqliteStore::new(db)) Ok(db)
}
pub async fn create_test_store() -> Result<SqliteStore, sqlx::Error> {
Ok(SqliteStore::new(create_test_db().await?))
} }