Skip to content

Commit

Permalink
re-blessed all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Nov 15, 2024
1 parent d885897 commit 840985b
Show file tree
Hide file tree
Showing 52 changed files with 156 additions and 157 deletions.
35 changes: 10 additions & 25 deletions martin/src/bin/martin-cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
152 changes: 70 additions & 82 deletions martin/src/pg/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,142 +496,130 @@ 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:
from_schemas: public
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:
from_schemas: public
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:
tables:
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: ~
"#);
}
}
10 changes: 4 additions & 6 deletions martin/tests/mb_server_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -73,7 +72,7 @@ async fn mbt_get_catalog() {
m_webp:
content_type: image/webp
name: ne2sr
"###);
");
}

#[actix_rt::test]
Expand All @@ -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:
Expand All @@ -105,7 +103,7 @@ async fn mbt_get_catalog_gzip() {
m_webp:
content_type: image/webp
name: ne2sr
"###);
");
}

#[actix_rt::test]
Expand Down
10 changes: 4 additions & 6 deletions martin/tests/pg_function_source_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
"###);
");
}
Loading

0 comments on commit 840985b

Please sign in to comment.