fix: fix some issues

This commit is contained in:
2025-05-04 03:59:59 +08:00
parent 3fe0538468
commit f245a68790
13 changed files with 99 additions and 36 deletions

View File

@@ -0,0 +1,9 @@
use crate::{
crypto::{CryptoConfig, CryptoService},
errors::RecorderResult,
};
pub async fn build_testing_crypto_service() -> RecorderResult<CryptoService> {
let crypto = CryptoService::from_config(CryptoConfig {}).await?;
Ok(crypto)
}

View File

@@ -5,7 +5,7 @@ use crate::{
#[cfg(feature = "testcontainers")]
pub async fn build_testing_database_service() -> RecorderResult<DatabaseService> {
use testcontainers::runners::AsyncRunner;
use testcontainers::{ImageExt, runners::AsyncRunner};
use testcontainers_ext::{ImageDefaultLogConsumerExt, ImagePruneExistedLabelExt};
use testcontainers_modules::postgres::Postgres;
@@ -13,6 +13,7 @@ pub async fn build_testing_database_service() -> RecorderResult<DatabaseService>
.with_db_name("konobangu")
.with_user("konobangu")
.with_password("konobangu")
.with_tag("17-alpine")
.with_default_log_consumer()
.with_prune_existed_label(env!("CARGO_PKG_NAME"), "postgres", true, true)
.await?;

View File

@@ -1,4 +1,5 @@
pub mod app;
pub mod crypto;
pub mod database;
pub mod mikan;
pub mod storage;

View File

@@ -5,6 +5,7 @@ pub fn try_init_testing_tracing(level: Level) {
let crate_name = env!("CARGO_PKG_NAME");
let level = level.as_str().to_lowercase();
let filter = EnvFilter::new(format!("{crate_name}[]={level}"))
.add_directive(format!("mockito[]={level}").parse().unwrap());
.add_directive(format!("mockito[]={level}").parse().unwrap())
.add_directive(format!("sqlx[]={level}").parse().unwrap());
let _ = tracing_subscriber::fmt().with_env_filter(filter).try_init();
}