mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
Janky fix for sqlite tests
This commit is contained in:
@@ -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]
|
||||||
|
|||||||
@@ -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?))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user