From ad8770a6e54c0fe6ee635b0d69d8b04ed00318c0 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Sat, 9 Dec 2023 00:54:23 -0500 Subject: [PATCH] Minor test update for tile copying --- martin/src/bin/martin-cp.rs | 2 +- mbtiles/src/copier.rs | 2 +- mbtiles/tests/mbtiles.rs | 14 ++++++++------ .../snapshots/mbtiles__databases@flat__dif.snap | 2 +- .../mbtiles__databases@flat__v1-no-hash.snap | 1 + .../snapshots/mbtiles__databases@flat__v1.snap | 3 ++- .../snapshots/mbtiles__databases@flat__v2.snap | 3 ++- .../snapshots/mbtiles__databases@hash__dif.snap | 2 +- .../mbtiles__databases@hash__v1-no-hash.snap | 1 + .../snapshots/mbtiles__databases@hash__v1.snap | 3 ++- .../snapshots/mbtiles__databases@hash__v2.snap | 3 ++- .../snapshots/mbtiles__databases@norm__dif.snap | 2 +- .../mbtiles__databases@norm__v1-no-hash.snap | 2 ++ .../snapshots/mbtiles__databases@norm__v1.snap | 4 +++- .../snapshots/mbtiles__databases@norm__v2.snap | 4 +++- 15 files changed, 31 insertions(+), 17 deletions(-) diff --git a/martin/src/bin/martin-cp.rs b/martin/src/bin/martin-cp.rs index 5a29a8d1d..277d2896f 100644 --- a/martin/src/bin/martin-cp.rs +++ b/martin/src/bin/martin-cp.rs @@ -79,7 +79,7 @@ pub struct CopyArgs { /// Number of concurrent connections to use. #[arg(long, default_value = "1")] pub concurrency: Option, - /// Bounds to copy. Can be specified multiple times. Overlapping regions will be handled correctly. + /// Bounds to copy, in the format `min_lon,min_lat,max_lon,max_lat`. Can be specified multiple times. Overlapping regions will be handled correctly. #[arg(long)] pub bbox: Vec, /// Minimum zoom level to copy diff --git a/mbtiles/src/copier.rs b/mbtiles/src/copier.rs index bcfa4a181..85bd3fd2a 100644 --- a/mbtiles/src/copier.rs +++ b/mbtiles/src/copier.rs @@ -100,12 +100,12 @@ impl MbtilesCopier { Self { src_file: src_filepath, dst_file: dst_filepath, - zoom_levels: Vec::default(), dst_type_cli: None, dst_type: None, on_duplicate: CopyDuplicateMode::Override, min_zoom: None, max_zoom: None, + zoom_levels: Vec::default(), diff_with_file: None, apply_patch: None, skip_agg_tiles_hash: false, diff --git a/mbtiles/tests/mbtiles.rs b/mbtiles/tests/mbtiles.rs index 5b586aa8c..407c1571d 100644 --- a/mbtiles/tests/mbtiles.rs +++ b/mbtiles/tests/mbtiles.rs @@ -17,7 +17,8 @@ use sqlx::{query, query_as, Executor as _, Row, SqliteConnection}; const TILES_V1: &str = " INSERT INTO tiles (zoom_level, tile_column, tile_row, tile_data) VALUES --(z, x, y, data) -- rules: keep if x=0, edit if x=1, remove if x=2 - (5, 0, 0, cast('same' as blob)) + (3, 6, 7, cast('root' as blob)) + , (5, 0, 0, cast('same' as blob)) , (5, 0, 1, cast('' as blob)) -- empty tile, keep , (5, 1, 1, cast('edit-v1' as blob)) , (5, 1, 2, cast('' as blob)) -- empty tile, edit @@ -32,7 +33,8 @@ const TILES_V1: &str = " const TILES_V2: &str = " INSERT INTO tiles (zoom_level, tile_column, tile_row, tile_data) VALUES - (5, 0, 0, cast('same' as blob)) -- no changes + (3, 6, 7, cast('root' as blob)) + , (5, 0, 0, cast('same' as blob)) -- no changes , (5, 0, 1, cast('' as blob)) -- no changes, empty tile , (5, 1, 1, cast('edit-v2' as blob)) -- edited in-place , (5, 1, 2, cast('not-empty' as blob)) -- edited in-place, replaced empty with non-empty @@ -198,7 +200,7 @@ fn databases() -> Databases { assert_snapshot!(&dmp, "{typ}__v1"); let hash = v1_mbt.validate(Off, Verify).await.unwrap(); allow_duplicates! { - assert_display_snapshot!(hash, @"096A8399D486CF443A5DF0CEC1AD8BB2"); + assert_display_snapshot!(hash, @"9ED9178D7025276336C783C2B54D6258"); } result.add("v1", mbt_typ, dmp, v1_mbt, v1_cn); @@ -208,7 +210,7 @@ fn databases() -> Databases { assert_snapshot!(&dmp, "{typ}__v2"); let hash = v2_mbt.validate(Off, Verify).await.unwrap(); allow_duplicates! { - assert_display_snapshot!(hash, @"FE0D3090E8B4E89F2C755C08E8D76BEA"); + assert_display_snapshot!(hash, @"3BCDEE3F52407FF1315629298CB99133"); } result.add("v2", mbt_typ, dmp, v2_mbt, v2_cn); @@ -312,7 +314,7 @@ async fn diff_and_patch( apply_patch(path(&tar1_mbt), path(&dif_mbt)).await?; let hash_v1 = tar1_mbt.validate(Off, Verify).await?; allow_duplicates! { - assert_display_snapshot!(hash_v1, @"FE0D3090E8B4E89F2C755C08E8D76BEA"); + assert_display_snapshot!(hash_v1, @"3BCDEE3F52407FF1315629298CB99133"); } let dmp = dump(&mut tar1_cn).await?; pretty_assert_eq!(&dmp, expected_v2); @@ -323,7 +325,7 @@ async fn diff_and_patch( apply_patch(path(&tar2_mbt), path(&dif_mbt)).await?; let hash_v2 = tar2_mbt.validate(Off, Verify).await?; allow_duplicates! { - assert_display_snapshot!(hash_v2, @"FE0D3090E8B4E89F2C755C08E8D76BEA"); + assert_display_snapshot!(hash_v2, @"3BCDEE3F52407FF1315629298CB99133"); } let dmp = dump(&mut tar2_cn).await?; pretty_assert_eq!(&dmp, expected_v2); diff --git a/mbtiles/tests/snapshots/mbtiles__databases@flat__dif.snap b/mbtiles/tests/snapshots/mbtiles__databases@flat__dif.snap index d5b5003ec..c31aeb6e7 100644 --- a/mbtiles/tests/snapshots/mbtiles__databases@flat__dif.snap +++ b/mbtiles/tests/snapshots/mbtiles__databases@flat__dif.snap @@ -11,7 +11,7 @@ CREATE TABLE metadata ( value text)''' values = [ '( "agg_tiles_hash", "B86122579EDCDD4C51F3910894FCC1A1" )', - '( "agg_tiles_hash_after_apply", "FE0D3090E8B4E89F2C755C08E8D76BEA" )', + '( "agg_tiles_hash_after_apply", "3BCDEE3F52407FF1315629298CB99133" )', '( "md-edit", "value - v2" )', '( "md-new", "value - new" )', '( "md-remove", NULL )', diff --git a/mbtiles/tests/snapshots/mbtiles__databases@flat__v1-no-hash.snap b/mbtiles/tests/snapshots/mbtiles__databases@flat__v1-no-hash.snap index d2d27f6d4..0dc4aae1c 100644 --- a/mbtiles/tests/snapshots/mbtiles__databases@flat__v1-no-hash.snap +++ b/mbtiles/tests/snapshots/mbtiles__databases@flat__v1-no-hash.snap @@ -26,6 +26,7 @@ CREATE TABLE tiles ( tile_data blob, PRIMARY KEY(zoom_level, tile_column, tile_row))''' values = [ + '( 3, 6, 7, blob(root) )', '( 5, 0, 0, blob(same) )', '( 5, 0, 1, blob() )', '( 5, 1, 1, blob(edit-v1) )', diff --git a/mbtiles/tests/snapshots/mbtiles__databases@flat__v1.snap b/mbtiles/tests/snapshots/mbtiles__databases@flat__v1.snap index 9f40369d0..74dcd43d3 100644 --- a/mbtiles/tests/snapshots/mbtiles__databases@flat__v1.snap +++ b/mbtiles/tests/snapshots/mbtiles__databases@flat__v1.snap @@ -10,7 +10,7 @@ CREATE TABLE metadata ( name text NOT NULL PRIMARY KEY, value text)''' values = [ - '( "agg_tiles_hash", "096A8399D486CF443A5DF0CEC1AD8BB2" )', + '( "agg_tiles_hash", "9ED9178D7025276336C783C2B54D6258" )', '( "md-edit", "value - v1" )', '( "md-remove", "value - remove" )', '( "md-same", "value - same" )', @@ -27,6 +27,7 @@ CREATE TABLE tiles ( tile_data blob, PRIMARY KEY(zoom_level, tile_column, tile_row))''' values = [ + '( 3, 6, 7, blob(root) )', '( 5, 0, 0, blob(same) )', '( 5, 0, 1, blob() )', '( 5, 1, 1, blob(edit-v1) )', diff --git a/mbtiles/tests/snapshots/mbtiles__databases@flat__v2.snap b/mbtiles/tests/snapshots/mbtiles__databases@flat__v2.snap index af065171f..2880dd1e6 100644 --- a/mbtiles/tests/snapshots/mbtiles__databases@flat__v2.snap +++ b/mbtiles/tests/snapshots/mbtiles__databases@flat__v2.snap @@ -10,7 +10,7 @@ CREATE TABLE metadata ( name text NOT NULL PRIMARY KEY, value text)''' values = [ - '( "agg_tiles_hash", "FE0D3090E8B4E89F2C755C08E8D76BEA" )', + '( "agg_tiles_hash", "3BCDEE3F52407FF1315629298CB99133" )', '( "md-edit", "value - v2" )', '( "md-new", "value - new" )', '( "md-same", "value - same" )', @@ -27,6 +27,7 @@ CREATE TABLE tiles ( tile_data blob, PRIMARY KEY(zoom_level, tile_column, tile_row))''' values = [ + '( 3, 6, 7, blob(root) )', '( 5, 0, 0, blob(same) )', '( 5, 0, 1, blob() )', '( 5, 1, 1, blob(edit-v2) )', diff --git a/mbtiles/tests/snapshots/mbtiles__databases@hash__dif.snap b/mbtiles/tests/snapshots/mbtiles__databases@hash__dif.snap index 7584b75db..5cab2712d 100644 --- a/mbtiles/tests/snapshots/mbtiles__databases@hash__dif.snap +++ b/mbtiles/tests/snapshots/mbtiles__databases@hash__dif.snap @@ -11,7 +11,7 @@ CREATE TABLE metadata ( value text)''' values = [ '( "agg_tiles_hash", "B86122579EDCDD4C51F3910894FCC1A1" )', - '( "agg_tiles_hash_after_apply", "FE0D3090E8B4E89F2C755C08E8D76BEA" )', + '( "agg_tiles_hash_after_apply", "3BCDEE3F52407FF1315629298CB99133" )', '( "md-edit", "value - v2" )', '( "md-new", "value - new" )', '( "md-remove", NULL )', diff --git a/mbtiles/tests/snapshots/mbtiles__databases@hash__v1-no-hash.snap b/mbtiles/tests/snapshots/mbtiles__databases@hash__v1-no-hash.snap index 163c7566e..130e90b0d 100644 --- a/mbtiles/tests/snapshots/mbtiles__databases@hash__v1-no-hash.snap +++ b/mbtiles/tests/snapshots/mbtiles__databases@hash__v1-no-hash.snap @@ -27,6 +27,7 @@ CREATE TABLE tiles_with_hash ( tile_hash text, PRIMARY KEY(zoom_level, tile_column, tile_row))''' values = [ + '( 3, 6, 7, blob(root), "63A9F0EA7BB98050796B649E85481845" )', '( 5, 0, 0, blob(same), "51037A4A37730F52C8732586D3AAA316" )', '( 5, 0, 1, blob(), "D41D8CD98F00B204E9800998ECF8427E" )', '( 5, 1, 1, blob(edit-v1), "EFE0AE5FD114DE99855BC2838BE97E1D" )', diff --git a/mbtiles/tests/snapshots/mbtiles__databases@hash__v1.snap b/mbtiles/tests/snapshots/mbtiles__databases@hash__v1.snap index a9c1e4ea1..343693334 100644 --- a/mbtiles/tests/snapshots/mbtiles__databases@hash__v1.snap +++ b/mbtiles/tests/snapshots/mbtiles__databases@hash__v1.snap @@ -10,7 +10,7 @@ CREATE TABLE metadata ( name text NOT NULL PRIMARY KEY, value text)''' values = [ - '( "agg_tiles_hash", "096A8399D486CF443A5DF0CEC1AD8BB2" )', + '( "agg_tiles_hash", "9ED9178D7025276336C783C2B54D6258" )', '( "md-edit", "value - v1" )', '( "md-remove", "value - remove" )', '( "md-same", "value - same" )', @@ -28,6 +28,7 @@ CREATE TABLE tiles_with_hash ( tile_hash text, PRIMARY KEY(zoom_level, tile_column, tile_row))''' values = [ + '( 3, 6, 7, blob(root), "63A9F0EA7BB98050796B649E85481845" )', '( 5, 0, 0, blob(same), "51037A4A37730F52C8732586D3AAA316" )', '( 5, 0, 1, blob(), "D41D8CD98F00B204E9800998ECF8427E" )', '( 5, 1, 1, blob(edit-v1), "EFE0AE5FD114DE99855BC2838BE97E1D" )', diff --git a/mbtiles/tests/snapshots/mbtiles__databases@hash__v2.snap b/mbtiles/tests/snapshots/mbtiles__databases@hash__v2.snap index abfa9ceff..da30138d6 100644 --- a/mbtiles/tests/snapshots/mbtiles__databases@hash__v2.snap +++ b/mbtiles/tests/snapshots/mbtiles__databases@hash__v2.snap @@ -10,7 +10,7 @@ CREATE TABLE metadata ( name text NOT NULL PRIMARY KEY, value text)''' values = [ - '( "agg_tiles_hash", "FE0D3090E8B4E89F2C755C08E8D76BEA" )', + '( "agg_tiles_hash", "3BCDEE3F52407FF1315629298CB99133" )', '( "md-edit", "value - v2" )', '( "md-new", "value - new" )', '( "md-same", "value - same" )', @@ -28,6 +28,7 @@ CREATE TABLE tiles_with_hash ( tile_hash text, PRIMARY KEY(zoom_level, tile_column, tile_row))''' values = [ + '( 3, 6, 7, blob(root), "63A9F0EA7BB98050796B649E85481845" )', '( 5, 0, 0, blob(same), "51037A4A37730F52C8732586D3AAA316" )', '( 5, 0, 1, blob(), "D41D8CD98F00B204E9800998ECF8427E" )', '( 5, 1, 1, blob(edit-v2), "FF76830FF90D79BB335884F256031731" )', diff --git a/mbtiles/tests/snapshots/mbtiles__databases@norm__dif.snap b/mbtiles/tests/snapshots/mbtiles__databases@norm__dif.snap index 95cf04a3b..2007f8b89 100644 --- a/mbtiles/tests/snapshots/mbtiles__databases@norm__dif.snap +++ b/mbtiles/tests/snapshots/mbtiles__databases@norm__dif.snap @@ -49,7 +49,7 @@ CREATE TABLE metadata ( value text)''' values = [ '( "agg_tiles_hash", "B86122579EDCDD4C51F3910894FCC1A1" )', - '( "agg_tiles_hash_after_apply", "FE0D3090E8B4E89F2C755C08E8D76BEA" )', + '( "agg_tiles_hash_after_apply", "3BCDEE3F52407FF1315629298CB99133" )', '( "md-edit", "value - v2" )', '( "md-new", "value - new" )', '( "md-remove", NULL )', diff --git a/mbtiles/tests/snapshots/mbtiles__databases@norm__v1-no-hash.snap b/mbtiles/tests/snapshots/mbtiles__databases@norm__v1-no-hash.snap index 79da9dcff..023d2352d 100644 --- a/mbtiles/tests/snapshots/mbtiles__databases@norm__v1-no-hash.snap +++ b/mbtiles/tests/snapshots/mbtiles__databases@norm__v1-no-hash.snap @@ -13,6 +13,7 @@ values = [ '( "0F6969D7052DA9261E31DDB6E88C136E", blob(remove) )', '( "51037A4A37730F52C8732586D3AAA316", blob(same) )', '( "535A5575B48444EDEB926815AB26EC9B", blob(1-keep-1-rm) )', + '( "63A9F0EA7BB98050796B649E85481845", blob(root) )', '( "720C02778717818CC0A869955BA2AFB6", blob(non-empty) )', '( "D41D8CD98F00B204E9800998ECF8427E", blob() )', '( "EFE0AE5FD114DE99855BC2838BE97E1D", blob(edit-v1) )', @@ -29,6 +30,7 @@ CREATE TABLE map ( tile_id text, PRIMARY KEY(zoom_level, tile_column, tile_row))''' values = [ + '( 3, 6, 7, "63A9F0EA7BB98050796B649E85481845" )', '( 5, 0, 0, "51037A4A37730F52C8732586D3AAA316" )', '( 5, 0, 1, "D41D8CD98F00B204E9800998ECF8427E" )', '( 5, 1, 1, "EFE0AE5FD114DE99855BC2838BE97E1D" )', diff --git a/mbtiles/tests/snapshots/mbtiles__databases@norm__v1.snap b/mbtiles/tests/snapshots/mbtiles__databases@norm__v1.snap index 32d7e7078..423b56fb5 100644 --- a/mbtiles/tests/snapshots/mbtiles__databases@norm__v1.snap +++ b/mbtiles/tests/snapshots/mbtiles__databases@norm__v1.snap @@ -13,6 +13,7 @@ values = [ '( "0F6969D7052DA9261E31DDB6E88C136E", blob(remove) )', '( "51037A4A37730F52C8732586D3AAA316", blob(same) )', '( "535A5575B48444EDEB926815AB26EC9B", blob(1-keep-1-rm) )', + '( "63A9F0EA7BB98050796B649E85481845", blob(root) )', '( "720C02778717818CC0A869955BA2AFB6", blob(non-empty) )', '( "D41D8CD98F00B204E9800998ECF8427E", blob() )', '( "EFE0AE5FD114DE99855BC2838BE97E1D", blob(edit-v1) )', @@ -29,6 +30,7 @@ CREATE TABLE map ( tile_id text, PRIMARY KEY(zoom_level, tile_column, tile_row))''' values = [ + '( 3, 6, 7, "63A9F0EA7BB98050796B649E85481845" )', '( 5, 0, 0, "51037A4A37730F52C8732586D3AAA316" )', '( 5, 0, 1, "D41D8CD98F00B204E9800998ECF8427E" )', '( 5, 1, 1, "EFE0AE5FD114DE99855BC2838BE97E1D" )', @@ -50,7 +52,7 @@ CREATE TABLE metadata ( name text NOT NULL PRIMARY KEY, value text)''' values = [ - '( "agg_tiles_hash", "096A8399D486CF443A5DF0CEC1AD8BB2" )', + '( "agg_tiles_hash", "9ED9178D7025276336C783C2B54D6258" )', '( "md-edit", "value - v1" )', '( "md-remove", "value - remove" )', '( "md-same", "value - same" )', diff --git a/mbtiles/tests/snapshots/mbtiles__databases@norm__v2.snap b/mbtiles/tests/snapshots/mbtiles__databases@norm__v2.snap index e7d9aac70..88c95bd06 100644 --- a/mbtiles/tests/snapshots/mbtiles__databases@norm__v2.snap +++ b/mbtiles/tests/snapshots/mbtiles__databases@norm__v2.snap @@ -14,6 +14,7 @@ values = [ '( "22AF645D1859CB5CA6DA0C484F1F37EA", blob(new) )', '( "51037A4A37730F52C8732586D3AAA316", blob(same) )', '( "535A5575B48444EDEB926815AB26EC9B", blob(1-keep-1-rm) )', + '( "63A9F0EA7BB98050796B649E85481845", blob(root) )', '( "99DEE0E66806ECF1C20C09F64B2C0A34", blob(not-empty) )', '( "D41D8CD98F00B204E9800998ECF8427E", blob() )', '( "FF76830FF90D79BB335884F256031731", blob(edit-v2) )', @@ -30,6 +31,7 @@ CREATE TABLE map ( tile_id text, PRIMARY KEY(zoom_level, tile_column, tile_row))''' values = [ + '( 3, 6, 7, "63A9F0EA7BB98050796B649E85481845" )', '( 5, 0, 0, "51037A4A37730F52C8732586D3AAA316" )', '( 5, 0, 1, "D41D8CD98F00B204E9800998ECF8427E" )', '( 5, 1, 1, "FF76830FF90D79BB335884F256031731" )', @@ -50,7 +52,7 @@ CREATE TABLE metadata ( name text NOT NULL PRIMARY KEY, value text)''' values = [ - '( "agg_tiles_hash", "FE0D3090E8B4E89F2C755C08E8D76BEA" )', + '( "agg_tiles_hash", "3BCDEE3F52407FF1315629298CB99133" )', '( "md-edit", "value - v2" )', '( "md-new", "value - new" )', '( "md-same", "value - same" )',