diff --git a/martin/src/bin/martin-cp.rs b/martin/src/bin/martin-cp.rs index 2bfb3b5cf..290f249c0 100644 --- a/martin/src/bin/martin-cp.rs +++ b/martin/src/bin/martin-cp.rs @@ -458,46 +458,31 @@ mod tests { let bbox_mi = Bounds::from_str("-86.6271,41.6811,-82.3095,45.8058").unwrap(); let bbox_usa = Bounds::from_str("-124.8489,24.3963,-66.8854,49.3843").unwrap(); - assert_yaml_snapshot!(compute_tile_ranges(&args(&[world], &[0])), @r###" - --- - - "0: (0,0) - (0,0)" - "###); + assert_yaml_snapshot!(compute_tile_ranges(&args(&[world], &[0])), @r#"- "0: (0,0) - (0,0)""#); - assert_yaml_snapshot!(compute_tile_ranges(&args(&[world], &[3,7])), @r###" - --- + assert_yaml_snapshot!(compute_tile_ranges(&args(&[world], &[3,7])), @r#" - "3: (0,0) - (7,7)" - "7: (0,0) - (127,127)" - "###); + "#); - assert_yaml_snapshot!(compute_tile_ranges(&arg_minmax(&[world], 2, 4)), @r###" - --- + assert_yaml_snapshot!(compute_tile_ranges(&arg_minmax(&[world], 2, 4)), @r#" - "2: (0,0) - (3,3)" - "3: (0,0) - (7,7)" - "4: (0,0) - (15,15)" - "###); + "#); - assert_yaml_snapshot!(compute_tile_ranges(&args(&[world], &[14])), @r###" - --- - - "14: (0,0) - (16383,16383)" - "###); + assert_yaml_snapshot!(compute_tile_ranges(&args(&[world], &[14])), @r#"- "14: (0,0) - (16383,16383)""#); - assert_yaml_snapshot!(compute_tile_ranges(&args(&[bbox_usa], &[14])), @r###" - --- - - "14: (2509,5599) - (5147,7046)" - "###); + assert_yaml_snapshot!(compute_tile_ranges(&args(&[bbox_usa], &[14])), @r#"- "14: (2509,5599) - (5147,7046)""#); - assert_yaml_snapshot!(compute_tile_ranges(&args(&[bbox_usa, bbox_mi, bbox_ca], &[14])), @r###" - --- - - "14: (2509,5599) - (5147,7046)" - "###); + assert_yaml_snapshot!(compute_tile_ranges(&args(&[bbox_usa, bbox_mi, bbox_ca], &[14])), @r#"- "14: (2509,5599) - (5147,7046)""#); - assert_yaml_snapshot!(compute_tile_ranges(&args(&[bbox_ca_south, bbox_mi, bbox_ca], &[14])), @r###" - --- + assert_yaml_snapshot!(compute_tile_ranges(&args(&[bbox_ca_south, bbox_mi, bbox_ca], &[14])), @r#" - "14: (2791,6499) - (2997,6624)" - "14: (4249,5841) - (4446,6101)" - "14: (2526,6081) - (2790,6624)" - "14: (2791,6081) - (2997,6498)" - "###); + "#); } fn args(bbox: &[Bounds], zooms: &[u8]) -> CopyArgs { diff --git a/martin/src/file_config.rs b/martin/src/file_config.rs index e222017cc..c9d9f052b 100644 --- a/martin/src/file_config.rs +++ b/martin/src/file_config.rs @@ -12,7 +12,7 @@ use crate::config::{copy_unrecognized_config, UnrecognizedValues}; use crate::file_config::FileError::{ InvalidFilePath, InvalidSourceFilePath, InvalidSourceUrl, IoError, }; -use crate::source::{Source, TileInfoSources}; +use crate::source::{TileInfoSource, TileInfoSources}; use crate::utils::{IdResolver, OptMainCache, OptOneMany}; use crate::MartinResult; use crate::OptOneMany::{Many, One}; @@ -70,13 +70,13 @@ pub trait SourceConfigExtras: ConfigExtras { &self, id: String, path: PathBuf, - ) -> impl std::future::Future>> + Send; + ) -> impl std::future::Future> + Send; fn new_sources_url( &self, id: String, url: Url, - ) -> impl std::future::Future>> + Send; + ) -> impl std::future::Future> + Send; } #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] diff --git a/martin/src/mbtiles/mod.rs b/martin/src/mbtiles/mod.rs index 2488098a0..31e6768d8 100644 --- a/martin/src/mbtiles/mod.rs +++ b/martin/src/mbtiles/mod.rs @@ -14,7 +14,7 @@ use url::Url; use crate::config::UnrecognizedValues; use crate::file_config::FileError::{AcquireConnError, InvalidMetadata, IoError}; use crate::file_config::{ConfigExtras, FileResult, SourceConfigExtras}; -use crate::source::{TileData, UrlQuery}; +use crate::source::{TileData, TileInfoSource, UrlQuery}; use crate::{MartinResult, Source}; #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] @@ -30,14 +30,14 @@ impl ConfigExtras for MbtConfig { } impl SourceConfigExtras for MbtConfig { - async fn new_sources(&self, id: String, path: PathBuf) -> FileResult> { + async fn new_sources(&self, id: String, path: PathBuf) -> FileResult { Ok(Box::new(MbtSource::new(id, path).await?)) } // TODO: Remove #[allow] after switching to Rust/Clippy v1.78+ in CI // See https://github.com/rust-lang/rust-clippy/pull/12323 #[allow(clippy::no_effect_underscore_binding)] - async fn new_sources_url(&self, _id: String, _url: Url) -> FileResult> { + async fn new_sources_url(&self, _id: String, _url: Url) -> FileResult { unreachable!() } } @@ -96,7 +96,7 @@ impl Source for MbtSource { self.tile_info } - fn clone_source(&self) -> Box { + fn clone_source(&self) -> TileInfoSource { Box::new(self.clone()) } diff --git a/martin/src/pg/builder.rs b/martin/src/pg/builder.rs index 4b88f2f93..cf81abc4b 100644 --- a/martin/src/pg/builder.rs +++ b/martin/src/pg/builder.rs @@ -496,95 +496,86 @@ mod tests { #[allow(clippy::too_many_lines)] fn test_auto_publish_no_auto() { let cfg = auto("{}"); - assert_yaml_snapshot!(cfg, @r###" - --- - auto_table: - source_id_format: "{table}" - auto_funcs: - source_id_format: "{function}" - "###); + assert_yaml_snapshot!(cfg, @r#" + auto_table: + source_id_format: "{table}" + auto_funcs: + source_id_format: "{function}" + "#); let cfg = auto("tables: {}"); - assert_yaml_snapshot!(cfg, @r###" - --- - auto_table: ~ - auto_funcs: ~ - "###); + assert_yaml_snapshot!(cfg, @r" + auto_table: ~ + auto_funcs: ~ + "); let cfg = auto("functions: {}"); - assert_yaml_snapshot!(cfg, @r###" - --- - auto_table: ~ - auto_funcs: ~ - "###); + assert_yaml_snapshot!(cfg, @r" + auto_table: ~ + auto_funcs: ~ + "); let cfg = auto("auto_publish: true"); - assert_yaml_snapshot!(cfg, @r###" - --- - auto_table: - source_id_format: "{table}" - auto_funcs: - source_id_format: "{function}" - "###); + assert_yaml_snapshot!(cfg, @r#" + auto_table: + source_id_format: "{table}" + auto_funcs: + source_id_format: "{function}" + "#); let cfg = auto("auto_publish: false"); - assert_yaml_snapshot!(cfg, @r###" - --- - auto_table: ~ - auto_funcs: ~ - "###); + assert_yaml_snapshot!(cfg, @r" + auto_table: ~ + auto_funcs: ~ + "); let cfg = auto(indoc! {" auto_publish: from_schemas: public tables: true"}); - assert_yaml_snapshot!(cfg, @r###" - --- - auto_table: - schemas: - - public - source_id_format: "{table}" - auto_funcs: ~ - "###); + assert_yaml_snapshot!(cfg, @r#" + auto_table: + schemas: + - public + source_id_format: "{table}" + auto_funcs: ~ + "#); let cfg = auto(indoc! {" auto_publish: from_schemas: public functions: true"}); - assert_yaml_snapshot!(cfg, @r###" - --- - auto_table: ~ - auto_funcs: - schemas: - - public - source_id_format: "{function}" - "###); + assert_yaml_snapshot!(cfg, @r#" + auto_table: ~ + auto_funcs: + schemas: + - public + source_id_format: "{function}" + "#); let cfg = auto(indoc! {" auto_publish: from_schemas: public tables: false"}); - assert_yaml_snapshot!(cfg, @r###" - --- - auto_table: ~ - auto_funcs: - schemas: - - public - source_id_format: "{function}" - "###); + assert_yaml_snapshot!(cfg, @r#" + auto_table: ~ + auto_funcs: + schemas: + - public + source_id_format: "{function}" + "#); let cfg = auto(indoc! {" auto_publish: from_schemas: public functions: false"}); - assert_yaml_snapshot!(cfg, @r###" - --- - auto_table: - schemas: - - public - source_id_format: "{table}" - auto_funcs: ~ - "###); + assert_yaml_snapshot!(cfg, @r#" + auto_table: + schemas: + - public + source_id_format: "{table}" + auto_funcs: ~ + "#); let cfg = auto(indoc! {" auto_publish: @@ -592,15 +583,14 @@ mod tests { tables: from_schemas: osm id_format: 'foo_{schema}.{table}_bar'"}); - assert_yaml_snapshot!(cfg, @r###" - --- - auto_table: - schemas: - - osm - - public - source_id_format: "foo_{schema}.{table}_bar" - auto_funcs: ~ - "###); + assert_yaml_snapshot!(cfg, @r#" + auto_table: + schemas: + - osm + - public + source_id_format: "foo_{schema}.{table}_bar" + auto_funcs: ~ + "#); let cfg = auto(indoc! {" auto_publish: @@ -608,15 +598,14 @@ mod tests { tables: from_schemas: osm source_id_format: '{schema}.{table}'"}); - assert_yaml_snapshot!(cfg, @r###" - --- + assert_yaml_snapshot!(cfg, @r#" auto_table: schemas: - osm - public source_id_format: "{schema}.{table}" auto_funcs: ~ - "###); + "#); let cfg = auto(indoc! {" auto_publish: @@ -624,14 +613,13 @@ mod tests { from_schemas: - osm - public"}); - assert_yaml_snapshot!(cfg, @r###" - --- - auto_table: - schemas: - - osm - - public - source_id_format: "{table}" - auto_funcs: ~ - "###); + assert_yaml_snapshot!(cfg, @r#" + auto_table: + schemas: + - osm + - public + source_id_format: "{table}" + auto_funcs: ~ + "#); } } diff --git a/martin/src/pg/pg_source.rs b/martin/src/pg/pg_source.rs index 8f1b34712..bfc989788 100644 --- a/martin/src/pg/pg_source.rs +++ b/martin/src/pg/pg_source.rs @@ -9,7 +9,7 @@ use tilejson::TileJSON; use crate::pg::pool::PgPool; use crate::pg::utils::query_to_json; use crate::pg::PgError::{GetTileError, GetTileWithQueryError, PrepareQueryError}; -use crate::source::{Source, TileData, UrlQuery}; +use crate::source::{Source, TileData, TileInfoSource, UrlQuery}; use crate::MartinResult; #[derive(Clone, Debug)] @@ -46,7 +46,7 @@ impl Source for PgSource { TileInfo::new(Mvt, Uncompressed) } - fn clone_source(&self) -> Box { + fn clone_source(&self) -> TileInfoSource { Box::new(self.clone()) } diff --git a/martin/src/pmtiles/mod.rs b/martin/src/pmtiles/mod.rs index c24b823b7..159b33b32 100644 --- a/martin/src/pmtiles/mod.rs +++ b/martin/src/pmtiles/mod.rs @@ -20,7 +20,7 @@ use url::Url; use crate::config::UnrecognizedValues; use crate::file_config::FileError::{InvalidMetadata, InvalidUrlMetadata, IoError}; use crate::file_config::{ConfigExtras, FileError, FileResult, SourceConfigExtras}; -use crate::source::UrlQuery; +use crate::source::{TileInfoSource, UrlQuery}; use crate::utils::cache::get_cached_value; use crate::utils::{CacheKey, CacheValue, OptMainCache}; use crate::{MartinResult, Source, TileData}; @@ -134,13 +134,13 @@ impl SourceConfigExtras for PmtConfig { true } - async fn new_sources(&self, id: String, path: PathBuf) -> FileResult> { + async fn new_sources(&self, id: String, path: PathBuf) -> FileResult { Ok(Box::new( PmtFileSource::new(self.new_cached_source(), id, path).await?, )) } - async fn new_sources_url(&self, id: String, url: Url) -> FileResult> { + async fn new_sources_url(&self, id: String, url: Url) -> FileResult { Ok(Box::new( PmtHttpSource::new( self.client.clone().unwrap(), @@ -250,7 +250,7 @@ macro_rules! impl_pmtiles_source { self.tile_info } - fn clone_source(&self) -> Box { + fn clone_source(&self) -> TileInfoSource { Box::new(self.clone()) } diff --git a/martin/src/srv/server.rs b/martin/src/srv/server.rs index 54517c9a7..7482e3ba3 100755 --- a/martin/src/srv/server.rs +++ b/martin/src/srv/server.rs @@ -201,7 +201,7 @@ pub mod tests { use tilejson::TileJSON; use super::*; - use crate::source::{Source, TileData}; + use crate::source::{Source, TileData, TileInfoSource}; use crate::UrlQuery; #[derive(Debug, Clone)] @@ -225,7 +225,7 @@ pub mod tests { TileInfo::new(Format::Mvt, Encoding::Uncompressed) } - fn clone_source(&self) -> Box { + fn clone_source(&self) -> TileInfoSource { Box::new(self.clone()) } diff --git a/martin/tests/mb_server_test.rs b/martin/tests/mb_server_test.rs index 327a88fe4..19f053f4d 100644 --- a/martin/tests/mb_server_test.rs +++ b/martin/tests/mb_server_test.rs @@ -53,8 +53,7 @@ async fn mbt_get_catalog() { let response = call_service(&app, req).await; let response = assert_response(response).await; let body: serde_json::Value = read_body_json(response).await; - assert_yaml_snapshot!(body, @r###" - --- + assert_yaml_snapshot!(body, @r" fonts: {} sprites: {} tiles: @@ -73,7 +72,7 @@ async fn mbt_get_catalog() { m_webp: content_type: image/webp name: ne2sr - "###); + "); } #[actix_rt::test] @@ -85,8 +84,7 @@ async fn mbt_get_catalog_gzip() { let response = assert_response(response).await; let body = decode_gzip(&read_body(response).await).unwrap(); let body: serde_json::Value = serde_json::from_slice(&body).unwrap(); - assert_yaml_snapshot!(body, @r###" - --- + assert_yaml_snapshot!(body, @r" fonts: {} sprites: {} tiles: @@ -105,7 +103,7 @@ async fn mbt_get_catalog_gzip() { m_webp: content_type: image/webp name: ne2sr - "###); + "); } #[actix_rt::test] diff --git a/martin/tests/pg_function_source_test.rs b/martin/tests/pg_function_source_test.rs index f10af4829..cf7d81718 100644 --- a/martin/tests/pg_function_source_test.rs +++ b/martin/tests/pg_function_source_test.rs @@ -17,14 +17,13 @@ fn init() { async fn function_source_tilejson() { let mock = mock_sources(mock_pgcfg("connection_string: $DATABASE_URL")).await; let tj = source(&mock, "function_zxy_query").get_tilejson(); - assert_yaml_snapshot!(tj, @r###" - --- + assert_yaml_snapshot!(tj, @r" tilejson: 3.0.0 tiles: [] name: function_zxy_query foo: bar: foo - "###); + "); } #[actix_rt::test] @@ -55,10 +54,9 @@ async fn function_source_schemas() { from_schemas: MixedCase "}); let sources = mock_sources(cfg).await.0.tiles; - assert_yaml_snapshot!(sources.get_catalog(), @r###" - --- + assert_yaml_snapshot!(sources.get_catalog(), @r" function_Mixed_Name: content_type: application/x-protobuf description: a function source with MixedCase name - "###); + "); } diff --git a/martin/tests/pg_server_test.rs b/martin/tests/pg_server_test.rs index 7fa96d2cf..34ca2dc0d 100644 --- a/martin/tests/pg_server_test.rs +++ b/martin/tests/pg_server_test.rs @@ -53,7 +53,6 @@ postgres: let body = read_body(response).await; let body: serde_json::Value = serde_json::from_slice(&body).unwrap(); assert_yaml_snapshot!(body, @r#" - --- fonts: {} sprites: {} tiles: @@ -188,8 +187,7 @@ postgres: .insert_header(("x-rewrite-url", "/tiles/table_source?token=martin")) .to_request(); let result: TileJSON = call_and_read_body_json(&app, req).await; - assert_yaml_snapshot!(result, @r###" - --- + assert_yaml_snapshot!(result, @r#" tilejson: 3.0.0 tiles: - "http://localhost:8080/tiles/table_source/{z}/{x}/{y}?token=martin" @@ -205,7 +203,7 @@ postgres: name: table_source foo: bar: foo - "###); + "#); } #[actix_rt::test] @@ -1025,8 +1023,7 @@ tables: assert_eq!(src.id_column, None); assert!(matches!(&src.properties, Some(v) if v.len() == 1)); let tj = source(&mock, "no_id").get_tilejson(); - assert_yaml_snapshot!(tj, @r###" - --- + assert_yaml_snapshot!(tj, @r" tilejson: 3.0.0 tiles: [] vector_layers: @@ -1041,10 +1038,9 @@ tables: - 90 description: a description from comment on table name: no_id - "###); + "); - assert_yaml_snapshot!(table(&mock, "id_only"), @r###" - --- + assert_yaml_snapshot!(table(&mock, "id_only"), @r" schema: MixedCase table: MixPoints srid: 4326 @@ -1058,10 +1054,9 @@ tables: geometry_type: POINT properties: TABLE: text - "###); + "); - assert_yaml_snapshot!(table(&mock, "id_and_prop"), @r###" - --- + assert_yaml_snapshot!(table(&mock, "id_and_prop"), @r" schema: MixedCase table: MixPoints srid: 4326 @@ -1076,10 +1071,9 @@ tables: properties: TABLE: text giD: int4 - "###); + "); - assert_yaml_snapshot!(table(&mock, "prop_only"), @r###" - --- + assert_yaml_snapshot!(table(&mock, "prop_only"), @r" schema: MixedCase table: MixPoints srid: 4326 @@ -1093,7 +1087,7 @@ tables: properties: TABLE: text giD: int4 - "###); + "); // -------------------------------------------- diff --git a/martin/tests/pg_table_source_test.rs b/martin/tests/pg_table_source_test.rs index 2fb627b69..0872c8644 100644 --- a/martin/tests/pg_table_source_test.rs +++ b/martin/tests/pg_table_source_test.rs @@ -17,7 +17,6 @@ async fn table_source() { let mock = mock_sources(mock_pgcfg("connection_string: $DATABASE_URL")).await; insta::with_settings!({sort_maps => true}, { assert_yaml_snapshot!(mock.0.tiles.get_catalog(), @r#" - --- "-function.withweired---_-characters": content_type: application/x-protobuf description: a function source with special characters diff --git a/martin/tests/pmt_server_test.rs b/martin/tests/pmt_server_test.rs index 63e8f775c..a7a26bbd6 100644 --- a/martin/tests/pmt_server_test.rs +++ b/martin/tests/pmt_server_test.rs @@ -51,14 +51,13 @@ async fn pmt_get_catalog() { let response = call_service(&app, req).await; let response = assert_response(response).await; let body: serde_json::Value = read_body_json(response).await; - assert_yaml_snapshot!(body, @r###" - --- + assert_yaml_snapshot!(body, @r" fonts: {} sprites: {} tiles: stamen_toner__raster_CC-BY-ODbL_z3: content_type: image/png - "###); + "); } #[actix_rt::test] @@ -70,14 +69,13 @@ async fn pmt_get_catalog_gzip() { let response = assert_response(response).await; let body = decode_gzip(&read_body(response).await).unwrap(); let body: serde_json::Value = serde_json::from_slice(&body).unwrap(); - assert_yaml_snapshot!(body, @r###" - --- + assert_yaml_snapshot!(body, @r" fonts: {} sprites: {} tiles: p_png: content_type: image/png - "###); + "); } #[actix_rt::test] diff --git a/mbtiles/src/summary.rs b/mbtiles/src/summary.rs index 095a194a7..c63082c7e 100644 --- a/mbtiles/src/summary.rs +++ b/mbtiles/src/summary.rs @@ -202,8 +202,7 @@ mod tests { init_mbtiles_schema(&mut conn, MbtType::Flat).await.unwrap(); let res = mbt.summary(&mut conn).await?; - assert_yaml_snapshot!(res, @r###" - --- + assert_yaml_snapshot!(res, @r" file_size: ~ mbt_type: Flat page_size: 512 @@ -216,7 +215,7 @@ mod tests { min_zoom: ~ max_zoom: ~ zoom_info: [] - "###); + "); Ok(()) } @@ -228,8 +227,7 @@ mod tests { let res = mbt.summary(&mut conn).await?; - assert_yaml_snapshot!(res, @r###" - --- + assert_yaml_snapshot!(res, @r" file_size: 49152 mbt_type: Flat page_size: 4096 @@ -316,7 +314,7 @@ mod tests { - -40.97989806962015 - 180.00000000000003 - 61.60639637138628 - "###); + "); Ok(()) }