mirror of
https://github.com/modrinth/code.git
synced 2026-07-31 13:16:38 +00:00
fix: create clickhouse db in tests only
This commit is contained in:
@@ -39,6 +39,14 @@ fn connect() -> clickhouse::error::Result<clickhouse::Client> {
|
|||||||
.with_validation(false))
|
.with_validation(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "test")]
|
||||||
|
pub async fn create_database(database: &str) -> clickhouse::error::Result<()> {
|
||||||
|
connect()?
|
||||||
|
.query(&format!("CREATE DATABASE IF NOT EXISTS {database}"))
|
||||||
|
.execute()
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn run_migrations() -> clickhouse::error::Result<()> {
|
pub async fn run_migrations() -> clickhouse::error::Result<()> {
|
||||||
run_migrations_on_database(&ENV.CLICKHOUSE_DATABASE).await
|
run_migrations_on_database(&ENV.CLICKHOUSE_DATABASE).await
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ pub async fn setup(db: &database::TemporaryDatabase) -> LabrinthConfig {
|
|||||||
let search_backend = db.search_backend.clone();
|
let search_backend = db.search_backend.clone();
|
||||||
let file_host: Arc<dyn FileHost> = Arc::new(file_hosting::MockHost::new());
|
let file_host: Arc<dyn FileHost> = Arc::new(file_hosting::MockHost::new());
|
||||||
let file_host = web::Data::<dyn FileHost>::from(file_host);
|
let file_host = web::Data::<dyn FileHost>::from(file_host);
|
||||||
|
clickhouse::create_database(&ENV.CLICKHOUSE_DATABASE)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
clickhouse::run_migrations().await.unwrap();
|
clickhouse::run_migrations().await.unwrap();
|
||||||
let mut clickhouse = clickhouse::init_client().await.unwrap();
|
let mut clickhouse = clickhouse::init_client().await.unwrap();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user