Skip to main content

doido_model/
testing.rs

1use doido_core::Result;
2use sea_orm::{Database, DatabaseConnection};
3
4pub struct TestDb {
5    conn: DatabaseConnection,
6}
7
8impl TestDb {
9    pub async fn new() -> Result<Self> {
10        let conn = Database::connect("sqlite::memory:")
11            .await
12            .map_err(|e| doido_core::anyhow::anyhow!("TestDb connect failed: {e}"))?;
13        Ok(Self { conn })
14    }
15
16    pub fn conn(&self) -> &DatabaseConnection {
17        &self.conn
18    }
19}