remove mock database

This commit is contained in:
Namekuji 2023-05-27 03:35:09 -04:00
parent f1f3e5976d
commit 737ccfe11c
No known key found for this signature in database
GPG Key ID: B541BD6E646CABC7
3 changed files with 0 additions and 17 deletions

View File

@ -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"] }

View File

@ -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)
}

View File

@ -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"] }