remove mock database
This commit is contained in:
parent
f1f3e5976d
commit
737ccfe11c
3 changed files with 0 additions and 17 deletions
|
@ -5,14 +5,8 @@ edition = "2021"
|
|||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[features]
|
||||
mock = ["sea-orm/mock"]
|
||||
|
||||
[dependencies]
|
||||
once_cell = "1.17.1"
|
||||
sea-orm = { version = "0.11.3", features = ["sqlx-postgres", "runtime-tokio-rustls"] }
|
||||
thiserror = "1.0.40"
|
||||
tokio = { version = "1.28.1", features = ["macros"] }
|
||||
|
||||
[dev-dependencies]
|
||||
sea-orm = { version = "0.11.3", features = ["sqlx-sqlite"] }
|
||||
|
|
|
@ -6,11 +6,6 @@ use crate::error::Error;
|
|||
|
||||
static DB_CONN: once_cell::sync::OnceCell<DatabaseConnection> = once_cell::sync::OnceCell::new();
|
||||
|
||||
#[cfg(feature = "mock")]
|
||||
static DB_MOCK: once_cell::sync::Lazy<DatabaseConnection> = once_cell::sync::Lazy::new(|| {
|
||||
sea_orm::MockDatabase::new(sea_orm::DatabaseBackend::Postgres).into_connection()
|
||||
});
|
||||
|
||||
pub async fn init_database(connection_uri: impl Into<String>) -> Result<(), Error> {
|
||||
let conn = Database::connect(connection_uri.into()).await?;
|
||||
DB_CONN.get_or_init(move || conn);
|
||||
|
@ -18,9 +13,6 @@ pub async fn init_database(connection_uri: impl Into<String>) -> Result<(), Erro
|
|||
}
|
||||
|
||||
pub fn get_database() -> Result<&'static DatabaseConnection, Error> {
|
||||
#[cfg(feature = "mock")]
|
||||
return Ok(&DB_MOCK);
|
||||
#[cfg(not(feature = "mock"))]
|
||||
DB_CONN.get().ok_or(Error::Uninitialized)
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,3 @@ thiserror = "1.0.40"
|
|||
tokio = { version = "1.28.1", features = ["sync"] }
|
||||
util = { path = "../util" }
|
||||
utoipa = "3.3.0"
|
||||
|
||||
[dev-dependencies]
|
||||
database = { path = "../database", features = ["mock"] }
|
||||
|
|
Loading…
Reference in a new issue