2025-05-30 09:26:47 +09:00
|
|
|
use std::{path::PathBuf, sync::LazyLock};
|
|
|
|
|
2025-06-24 22:06:25 +09:00
|
|
|
use sea_orm::{sea_query::{FromValueTuple, IntoValueTuple, ValueType}, ActiveModelBehavior, ActiveModelTrait, ColumnTrait, Condition, DatabaseConnection, EntityTrait, IntoActiveModel, ModelTrait, PrimaryKeyToColumn, PrimaryKeyTrait, Value};
|
|
|
|
use sea_orm::QueryFilter;
|
2025-05-30 09:26:47 +09:00
|
|
|
use tempfile::TempDir;
|
2025-06-19 07:24:44 +09:00
|
|
|
use crate::{ config::PartialConfig, message::Message};
|
|
|
|
|
|
|
|
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
|
|
|
|
2025-05-30 09:26:47 +09:00
|
|
|
|
|
|
|
pub static TEST_DIR_PATH: LazyLock<PathBuf> = LazyLock::new(|| {
|
|
|
|
let pkg_name = env!("CARGO_PKG_NAME");
|
|
|
|
let timestamp = chrono::Local::now().to_rfc3339_opts(chrono::SecondsFormat::Nanos, false);
|
|
|
|
std::env::temp_dir().join(pkg_name).join( ×tamp)
|
|
|
|
});
|
|
|
|
|
|
|
|
pub static TEST_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
|
|
|
|
TempDir::new().unwrap().keep()
|
|
|
|
});
|
|
|
|
|
|
|
|
pub static TEST_DATABASE_PATH: std::sync::LazyLock<PathBuf> = std::sync::LazyLock::new(|| {
|
|
|
|
TEST_DIR_PATH.join("lazy-supplements.sqlite")
|
|
|
|
});
|
2025-06-19 07:24:44 +09:00
|
|
|
|
2025-06-22 11:29:44 +09:00
|
|
|
pub trait TestDefault {
|
|
|
|
fn test_default() -> Self;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait GlobalTestDefault<T: 'static> {
|
|
|
|
async fn get_or_init_test_default(&'static self) -> &'static T;
|
|
|
|
}
|