martin/tests/utils/mod.rs
Yuri Astrakhan f23da97691
tests, report unknown cfg, rm catalog vector flds (#551)
* clean up reporting of the un-used config params - instead of printing,
collect them and print in one place if needed (allows testing too)
* remove `vector_layer` in catalog - too verbose, not needed - can be
received via tilejson for individual source
* clean up tests so that they all use the same config yaml
2023-01-12 11:48:15 -05:00

32 lines
912 B
Rust

#![allow(clippy::missing_panics_doc)]
#![allow(clippy::redundant_clone)]
#![allow(clippy::unused_async)]
mod pg_utils;
use actix_web::web::Data;
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<AppState> {
Data::new(AppState { sources })
}
#[must_use]
pub fn mock_cfg(yaml: &str) -> Config {
let Ok(db_url) = std::env::var("DATABASE_URL") else {
panic!("DATABASE_URL env var is not set. Unable to do integration tests");
};
let env = FauxEnv(vec![("DATABASE_URL", db_url.into())].into_iter().collect());
let mut cfg: Config = subst::yaml::from_str(yaml, &env).unwrap();
let res = cfg.finalize().unwrap();
assert!(res.is_empty(), "unrecognized config: {res:?}");
cfg
}