mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 13:32:16 +00:00
store: test preparations
This commit is contained in:
@@ -11,6 +11,9 @@ mod secret;
|
||||
mod subscription_store;
|
||||
pub mod synctoken;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests;
|
||||
|
||||
pub use addressbook_store::AddressbookStore;
|
||||
pub use calendar_store::CalendarStore;
|
||||
pub use combined_calendar_store::CombinedCalendarStore;
|
||||
|
||||
0
crates/store/src/tests/mod.rs
Normal file
0
crates/store/src/tests/mod.rs
Normal file
@@ -8,6 +8,9 @@ pub mod error;
|
||||
pub mod principal_store;
|
||||
pub mod subscription_store;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, sqlx::Type)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub(crate) enum ChangeOperation {
|
||||
@@ -42,13 +45,3 @@ pub async fn create_db_pool(db_url: &str, migrate: bool) -> Result<Pool<Sqlite>,
|
||||
}
|
||||
Ok(db)
|
||||
}
|
||||
|
||||
pub async fn create_test_db() -> Result<SqlitePool, sqlx::Error> {
|
||||
let db = SqlitePool::connect("sqlite::memory:").await?;
|
||||
sqlx::migrate!("./migrations").run(&db).await?;
|
||||
Ok(db)
|
||||
}
|
||||
|
||||
pub async fn create_test_store() -> Result<SqliteStore, sqlx::Error> {
|
||||
Ok(SqliteStore::new(create_test_db().await?))
|
||||
}
|
||||
|
||||
13
crates/store_sqlite/src/tests/mod.rs
Normal file
13
crates/store_sqlite/src/tests/mod.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
use crate::SqliteStore;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
pub async fn create_test_db() -> Result<SqlitePool, sqlx::Error> {
|
||||
let db = SqlitePool::connect("sqlite::memory:").await?;
|
||||
sqlx::migrate!("./migrations").run(&db).await?;
|
||||
Ok(db)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_create_store() {
|
||||
SqliteStore::new(create_test_db().await.unwrap());
|
||||
}
|
||||
Reference in New Issue
Block a user