Skip to content

Commit

Permalink
Minor test update for tile copying
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Dec 9, 2023
1 parent 280dbe1 commit ad8770a
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion martin/src/bin/martin-cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub struct CopyArgs {
/// Number of concurrent connections to use.
#[arg(long, default_value = "1")]
pub concurrency: Option<usize>,
/// 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<Bounds>,
/// Minimum zoom level to copy
Expand Down
2 changes: 1 addition & 1 deletion mbtiles/src/copier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 8 additions & 6 deletions mbtiles/tests/mbtiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion mbtiles/tests/snapshots/mbtiles__databases@flat__dif.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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 )',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) )',
Expand Down
3 changes: 2 additions & 1 deletion mbtiles/tests/snapshots/mbtiles__databases@flat__v1.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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" )',
Expand All @@ -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) )',
Expand Down
3 changes: 2 additions & 1 deletion mbtiles/tests/snapshots/mbtiles__databases@flat__v2.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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" )',
Expand All @@ -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) )',
Expand Down
2 changes: 1 addition & 1 deletion mbtiles/tests/snapshots/mbtiles__databases@hash__dif.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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 )',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" )',
Expand Down
3 changes: 2 additions & 1 deletion mbtiles/tests/snapshots/mbtiles__databases@hash__v1.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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" )',
Expand All @@ -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" )',
Expand Down
3 changes: 2 additions & 1 deletion mbtiles/tests/snapshots/mbtiles__databases@hash__v2.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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" )',
Expand All @@ -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" )',
Expand Down
2 changes: 1 addition & 1 deletion mbtiles/tests/snapshots/mbtiles__databases@norm__dif.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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 )',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) )',
Expand All @@ -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" )',
Expand Down
4 changes: 3 additions & 1 deletion mbtiles/tests/snapshots/mbtiles__databases@norm__v1.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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) )',
Expand All @@ -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" )',
Expand All @@ -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" )',
Expand Down
4 changes: 3 additions & 1 deletion mbtiles/tests/snapshots/mbtiles__databases@norm__v2.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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) )',
Expand All @@ -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" )',
Expand All @@ -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" )',
Expand Down

0 comments on commit ad8770a

Please sign in to comment.