mirror of
https://github.com/maplibre/martin.git
synced 2024-12-24 23:45:42 +03:00
911076e3bc
* remove most of the utils:: and dev:: namespace usage * rename `configure_db_source` to `configure_db_sources` * use defaults from other table info objects (using the `..obj` syntax) * use doc comments vs regular comment in a few places * refactor server_test.rs to make it more readable and much shorter * use a macro for identical code * use a test_get() for identical GET request * rename fn test_foo() into fn foo() for simplicity
70 lines
2.2 KiB
Rust
70 lines
2.2 KiB
Rust
use log::info;
|
|
use martin::pg::dev::make_pool;
|
|
use martin::pg::function_source::get_function_sources;
|
|
use martin::source::{Source, Xyz};
|
|
|
|
fn init() {
|
|
let _ = env_logger::builder().is_test(true).try_init();
|
|
}
|
|
|
|
#[actix_rt::test]
|
|
async fn get_function_sources_ok() {
|
|
init();
|
|
|
|
let pool = make_pool().await;
|
|
let mut connection = pool.get().await.unwrap();
|
|
let function_sources = get_function_sources(&mut connection).await.unwrap();
|
|
|
|
info!("function_sources = {function_sources:#?}");
|
|
|
|
assert!(!function_sources.is_empty());
|
|
assert!(function_sources.contains_key("public.function_source"));
|
|
|
|
let function_source = function_sources.get("public.function_source").unwrap();
|
|
assert_eq!(function_source.schema, "public");
|
|
assert_eq!(function_source.function, "function_source");
|
|
assert_eq!(function_source.minzoom, None);
|
|
assert_eq!(function_source.maxzoom, None);
|
|
assert_eq!(function_source.bounds, None);
|
|
}
|
|
|
|
#[actix_rt::test]
|
|
async fn function_source_tilejson_ok() {
|
|
init();
|
|
|
|
let pool = make_pool().await;
|
|
let mut connection = pool.get().await.unwrap();
|
|
let function_sources = get_function_sources(&mut connection).await.unwrap();
|
|
|
|
let function_source = function_sources.get("public.function_source").unwrap();
|
|
let tilejson = function_source.get_tilejson().await.unwrap();
|
|
|
|
info!("tilejson = {tilejson:#?}");
|
|
|
|
assert_eq!(tilejson.tilejson, "2.2.0");
|
|
assert_eq!(tilejson.version, Some("1.0.0".to_owned()));
|
|
assert_eq!(tilejson.name, Some("public.function_source".to_owned()));
|
|
assert_eq!(tilejson.scheme, Some("xyz".to_owned()));
|
|
assert_eq!(tilejson.minzoom, Some(0));
|
|
assert_eq!(tilejson.maxzoom, Some(30));
|
|
assert!(tilejson.bounds.is_some());
|
|
assert!(tilejson.tiles.is_empty());
|
|
}
|
|
|
|
#[actix_rt::test]
|
|
async fn function_source_tile_ok() {
|
|
init();
|
|
|
|
let pool = make_pool().await;
|
|
let mut connection = pool.get().await.unwrap();
|
|
let function_sources = get_function_sources(&mut connection).await.unwrap();
|
|
|
|
let function_source = function_sources.get("public.function_source").unwrap();
|
|
let tile = function_source
|
|
.get_tile(&mut connection, &Xyz { x: 0, y: 0, z: 0 }, &None)
|
|
.await
|
|
.unwrap();
|
|
|
|
assert!(!tile.is_empty());
|
|
}
|