mirror of
https://github.com/maplibre/martin.git
synced 2024-12-30 10:22:27 +03:00
7e20602079
* moved `IdResolver` to a separate file * added `just fmt2` build target to format code using nightly mode * moved all Actix `Data<AppState>` into individual state objects, e.g. `Data<Sources>` (allows other source types, separate from `Sources` type) * move all Source-related code to a new `Sources` struct (a simple wrapper over a HashMap)
35 lines
964 B
Rust
35 lines
964 B
Rust
#![allow(clippy::missing_panics_doc)]
|
|
#![allow(clippy::redundant_clone)]
|
|
#![allow(clippy::unused_async)]
|
|
|
|
mod pg_utils;
|
|
|
|
use actix_web::web::Data;
|
|
use log::warn;
|
|
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::*;
|
|
|
|
pub async fn mock_app_data(sources: Sources) -> Data<Sources> {
|
|
Data::new(sources)
|
|
}
|
|
|
|
#[must_use]
|
|
pub fn mock_cfg(yaml: &str) -> Config {
|
|
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()
|
|
};
|
|
let mut cfg: Config = subst::yaml::from_str(yaml, &env).unwrap();
|
|
let res = cfg.finalize().unwrap();
|
|
assert!(res.is_empty(), "unrecognized config: {res:?}");
|
|
cfg
|
|
}
|