2023-01-03 19:09:41 +03:00
|
|
|
#![allow(clippy::missing_panics_doc)]
|
|
|
|
#![allow(clippy::redundant_clone)]
|
|
|
|
#![allow(clippy::unused_async)]
|
|
|
|
|
|
|
|
mod pg_utils;
|
|
|
|
|
|
|
|
use actix_web::web::Data;
|
2023-02-20 18:44:22 +03:00
|
|
|
use log::warn;
|
2023-01-03 19:09:41 +03:00
|
|
|
use martin::srv::AppState;
|
|
|
|
use martin::{Config, Sources};
|
|
|
|
pub use pg_utils::*;
|
|
|
|
|
|
|
|
#[path = "../../src/utils/test_utils.rs"]
|
|
|
|
mod test_utils;
|
|
|
|
#[allow(clippy::wildcard_imports)]
|
|
|
|
pub use test_utils::*;
|
|
|
|
|
2023-06-16 01:36:41 +03:00
|
|
|
pub async fn mock_app_data(sources: Sources) -> Data<Sources> {
|
|
|
|
Data::new(sources)
|
2023-01-03 19:09:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[must_use]
|
|
|
|
pub fn mock_cfg(yaml: &str) -> Config {
|
2023-02-20 18:44:22 +03:00
|
|
|
let env = if let Ok(db_url) = std::env::var("DATABASE_URL") {
|
|
|
|
FauxEnv(vec![("DATABASE_URL", db_url.into())].into_iter().collect())
|
|
|
|
} else {
|
|
|
|
warn!("DATABASE_URL env var is not set. Might not be able to do integration tests");
|
|
|
|
FauxEnv::default()
|
2023-01-03 19:09:41 +03:00
|
|
|
};
|
|
|
|
let mut cfg: Config = subst::yaml::from_str(yaml, &env).unwrap();
|
2023-01-12 19:48:15 +03:00
|
|
|
let res = cfg.finalize().unwrap();
|
|
|
|
assert!(res.is_empty(), "unrecognized config: {res:?}");
|
2023-01-03 19:09:41 +03:00
|
|
|
cfg
|
|
|
|
}
|