Skip to content

Commit

Permalink
moved test files
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Sep 29, 2023
1 parent 62a13fd commit c00f12f
Show file tree
Hide file tree
Showing 30 changed files with 79 additions and 81 deletions.
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ git-pre-push: stop start
# Update sqlite database schema.
prepare-sqlite: install-sqlx
mkdir -p martin-mbtiles/.sqlx
cd martin-mbtiles && cargo sqlx prepare --database-url sqlite://$PWD/../tests/fixtures/files/world_cities.mbtiles -- --lib --tests
cd martin-mbtiles && cargo sqlx prepare --database-url sqlite://$PWD/../tests/fixtures/mbtiles/world_cities.mbtiles -- --lib --tests

# Install SQLX cli if not already installed.
[private]
Expand Down
18 changes: 9 additions & 9 deletions martin-mbtiles/src/mbtiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,15 +609,15 @@ mod tests {

#[actix_rt::test]
async fn mbtiles_meta() {
let filepath = "../tests/fixtures/files/geography-class-jpg.mbtiles";
let filepath = "../tests/fixtures/mbtiles/geography-class-jpg.mbtiles";
let mbt = Mbtiles::new(filepath).unwrap();
assert_eq!(mbt.filepath(), filepath);
assert_eq!(mbt.filename(), "geography-class-jpg");
}

#[actix_rt::test]
async fn metadata_jpeg() {
let (mut conn, mbt) = open("../tests/fixtures/files/geography-class-jpg.mbtiles").await;
let (mut conn, mbt) = open("../tests/fixtures/mbtiles/geography-class-jpg.mbtiles").await;
let metadata = mbt.get_metadata(&mut conn).await.unwrap();
let tj = metadata.tilejson;

Expand All @@ -634,7 +634,7 @@ mod tests {

#[actix_rt::test]
async fn metadata_mvt() {
let (mut conn, mbt) = open("../tests/fixtures/files/world_cities.mbtiles").await;
let (mut conn, mbt) = open("../tests/fixtures/mbtiles/world_cities.mbtiles").await;
let metadata = mbt.get_metadata(&mut conn).await.unwrap();
let tj = metadata.tilejson;

Expand Down Expand Up @@ -665,7 +665,7 @@ mod tests {

#[actix_rt::test]
async fn metadata_get_key() {
let (mut conn, mbt) = open("../tests/fixtures/files/world_cities.mbtiles").await;
let (mut conn, mbt) = open("../tests/fixtures/mbtiles/world_cities.mbtiles").await;

let res = mbt.get_metadata_value(&mut conn, "bounds").await.unwrap();
assert_eq!(res.unwrap(), "-123.123590,-37.818085,174.763027,59.352706");
Expand Down Expand Up @@ -725,15 +725,15 @@ mod tests {

#[actix_rt::test]
async fn detect_type() {
let (mut conn, mbt) = open("../tests/fixtures/files/world_cities.mbtiles").await;
let (mut conn, mbt) = open("../tests/fixtures/mbtiles/world_cities.mbtiles").await;
let res = mbt.detect_type(&mut conn).await.unwrap();
assert_eq!(res, MbtType::Flat);

let (mut conn, mbt) = open("../tests/fixtures/files/zoomed_world_cities.mbtiles").await;
let (mut conn, mbt) = open("../tests/fixtures/mbtiles/zoomed_world_cities.mbtiles").await;
let res = mbt.detect_type(&mut conn).await.unwrap();
assert_eq!(res, MbtType::FlatWithHash);

let (mut conn, mbt) = open("../tests/fixtures/files/geography-class-jpg.mbtiles").await;
let (mut conn, mbt) = open("../tests/fixtures/mbtiles/geography-class-jpg.mbtiles").await;
let res = mbt.detect_type(&mut conn).await.unwrap();
assert_eq!(res, MbtType::Normalized);

Expand All @@ -744,7 +744,7 @@ mod tests {

#[actix_rt::test]
async fn validate_valid_file() {
let (mut conn, mbt) = open("../tests/fixtures/files/zoomed_world_cities.mbtiles").await;
let (mut conn, mbt) = open("../tests/fixtures/mbtiles/zoomed_world_cities.mbtiles").await;

mbt.check_integrity(&mut conn, IntegrityCheckType::Quick)
.await
Expand All @@ -754,7 +754,7 @@ mod tests {
#[actix_rt::test]
async fn validate_invalid_file() {
let (mut conn, mbt) =
open("../tests/fixtures/files/invalid/invalid_zoomed_world_cities.mbtiles").await;
open("../tests/fixtures/files/invalid_zoomed_world_cities.mbtiles").await;
let result = mbt.check_agg_tiles_hashes(&mut conn).await;
assert!(matches!(result, Err(MbtError::AggHashMismatch(..))));
}
Expand Down
54 changes: 27 additions & 27 deletions martin-mbtiles/src/tile_copier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,14 +603,14 @@ mod tests {

#[actix_rt::test]
async fn copy_flat_tables() -> MbtResult<()> {
let src = PathBuf::from("../tests/fixtures/files/world_cities.mbtiles");
let src = PathBuf::from("../tests/fixtures/mbtiles/world_cities.mbtiles");
let dst = PathBuf::from("file:copy_flat_tables_mem_db?mode=memory&cache=shared");
verify_copy_all(src, dst, None, Flat).await
}

#[actix_rt::test]
async fn copy_flat_from_flat_with_hash_tables() -> MbtResult<()> {
let src = PathBuf::from("../tests/fixtures/files/zoomed_world_cities.mbtiles");
let src = PathBuf::from("../tests/fixtures/mbtiles/zoomed_world_cities.mbtiles");
let dst = PathBuf::from(
"file:copy_flat_from_flat_with_hash_tables_mem_db?mode=memory&cache=shared",
);
Expand All @@ -619,22 +619,22 @@ mod tests {

#[actix_rt::test]
async fn copy_flat_from_normalized_tables() -> MbtResult<()> {
let src = PathBuf::from("../tests/fixtures/files/geography-class-png.mbtiles");
let src = PathBuf::from("../tests/fixtures/mbtiles/geography-class-png.mbtiles");
let dst =
PathBuf::from("file:copy_flat_from_normalized_tables_mem_db?mode=memory&cache=shared");
verify_copy_all(src, dst, Some(Flat), Flat).await
}

#[actix_rt::test]
async fn copy_flat_with_hash_tables() -> MbtResult<()> {
let src = PathBuf::from("../tests/fixtures/files/zoomed_world_cities.mbtiles");
let src = PathBuf::from("../tests/fixtures/mbtiles/zoomed_world_cities.mbtiles");
let dst = PathBuf::from("file:copy_flat_with_hash_tables_mem_db?mode=memory&cache=shared");
verify_copy_all(src, dst, None, FlatWithHash).await
}

#[actix_rt::test]
async fn copy_flat_with_hash_from_flat_tables() -> MbtResult<()> {
let src = PathBuf::from("../tests/fixtures/files/world_cities.mbtiles");
let src = PathBuf::from("../tests/fixtures/mbtiles/world_cities.mbtiles");
let dst = PathBuf::from(
"file:copy_flat_with_hash_from_flat_tables_mem_db?mode=memory&cache=shared",
);
Expand All @@ -643,7 +643,7 @@ mod tests {

#[actix_rt::test]
async fn copy_flat_with_hash_from_normalized_tables() -> MbtResult<()> {
let src = PathBuf::from("../tests/fixtures/files/geography-class-png.mbtiles");
let src = PathBuf::from("../tests/fixtures/mbtiles/geography-class-png.mbtiles");
let dst = PathBuf::from(
"file:copy_flat_with_hash_from_normalized_tables_mem_db?mode=memory&cache=shared",
);
Expand All @@ -652,22 +652,22 @@ mod tests {

#[actix_rt::test]
async fn copy_normalized_tables() -> MbtResult<()> {
let src = PathBuf::from("../tests/fixtures/files/geography-class-png.mbtiles");
let src = PathBuf::from("../tests/fixtures/mbtiles/geography-class-png.mbtiles");
let dst = PathBuf::from("file:copy_normalized_tables_mem_db?mode=memory&cache=shared");
verify_copy_all(src, dst, None, Normalized).await
}

#[actix_rt::test]
async fn copy_normalized_from_flat_tables() -> MbtResult<()> {
let src = PathBuf::from("../tests/fixtures/files/world_cities.mbtiles");
let src = PathBuf::from("../tests/fixtures/mbtiles/world_cities.mbtiles");
let dst =
PathBuf::from("file:copy_normalized_from_flat_tables_mem_db?mode=memory&cache=shared");
verify_copy_all(src, dst, Some(Normalized), Normalized).await
}

#[actix_rt::test]
async fn copy_normalized_from_flat_with_hash_tables() -> MbtResult<()> {
let src = PathBuf::from("../tests/fixtures/files/zoomed_world_cities.mbtiles");
let src = PathBuf::from("../tests/fixtures/mbtiles/zoomed_world_cities.mbtiles");
let dst = PathBuf::from(
"file:copy_normalized_from_flat_with_hash_tables_mem_db?mode=memory&cache=shared",
);
Expand All @@ -676,7 +676,7 @@ mod tests {

#[actix_rt::test]
async fn copy_with_min_max_zoom() -> MbtResult<()> {
let src = PathBuf::from("../tests/fixtures/files/world_cities.mbtiles");
let src = PathBuf::from("../tests/fixtures/mbtiles/world_cities.mbtiles");
let dst = PathBuf::from("file:copy_with_min_max_zoom_mem_db?mode=memory&cache=shared");
let opt = TileCopierOptions::new(src, dst)
.min_zoom(Some(2))
Expand All @@ -686,7 +686,7 @@ mod tests {

#[actix_rt::test]
async fn copy_with_zoom_levels() -> MbtResult<()> {
let src = PathBuf::from("../tests/fixtures/files/world_cities.mbtiles");
let src = PathBuf::from("../tests/fixtures/mbtiles/world_cities.mbtiles");
let dst = PathBuf::from("file:copy_with_zoom_levels_mem_db?mode=memory&cache=shared");
let opt = TileCopierOptions::new(src, dst)
.min_zoom(Some(2))
Expand All @@ -697,11 +697,11 @@ mod tests {

#[actix_rt::test]
async fn copy_with_diff_with_file() -> MbtResult<()> {
let src = PathBuf::from("../tests/fixtures/files/geography-class-jpg.mbtiles");
let src = PathBuf::from("../tests/fixtures/mbtiles/geography-class-jpg.mbtiles");
let dst = PathBuf::from("file:copy_with_diff_with_file_mem_db?mode=memory&cache=shared");

let diff_file =
PathBuf::from("../tests/fixtures/files/geography-class-jpg-modified.mbtiles");
PathBuf::from("../tests/fixtures/mbtiles/geography-class-jpg-modified.mbtiles");

let copy_opts =
TileCopierOptions::new(src.clone(), dst.clone()).diff_with_file(diff_file.clone());
Expand Down Expand Up @@ -744,10 +744,10 @@ mod tests {

#[actix_rt::test]
async fn ignore_dst_type_when_copy_to_existing() -> MbtResult<()> {
let src_file = PathBuf::from("../tests/fixtures/files/world_cities_modified.mbtiles");
let src_file = PathBuf::from("../tests/fixtures/mbtiles/world_cities_modified.mbtiles");

// Copy the dst file to an in-memory DB
let dst_file = PathBuf::from("../tests/fixtures/files/world_cities.mbtiles");
let dst_file = PathBuf::from("../tests/fixtures/mbtiles/world_cities.mbtiles");
let dst = PathBuf::from(
"file:ignore_dst_type_when_copy_to_existing_mem_db?mode=memory&cache=shared",
);
Expand All @@ -761,8 +761,8 @@ mod tests {

#[actix_rt::test]
async fn copy_to_existing_abort_mode() {
let src = PathBuf::from("../tests/fixtures/files/world_cities_modified.mbtiles");
let dst = PathBuf::from("../tests/fixtures/files/world_cities.mbtiles");
let src = PathBuf::from("../tests/fixtures/mbtiles/world_cities_modified.mbtiles");
let dst = PathBuf::from("../tests/fixtures/mbtiles/world_cities.mbtiles");

let copy_opts =
TileCopierOptions::new(src.clone(), dst.clone()).on_duplicate(CopyDuplicateMode::Abort);
Expand All @@ -775,10 +775,10 @@ mod tests {

#[actix_rt::test]
async fn copy_to_existing_override_mode() -> MbtResult<()> {
let src_file = PathBuf::from("../tests/fixtures/files/world_cities_modified.mbtiles");
let src_file = PathBuf::from("../tests/fixtures/mbtiles/world_cities_modified.mbtiles");

// Copy the dst file to an in-memory DB
let dst_file = PathBuf::from("../tests/fixtures/files/world_cities.mbtiles");
let dst_file = PathBuf::from("../tests/fixtures/mbtiles/world_cities.mbtiles");
let dst =
PathBuf::from("file:copy_to_existing_override_mode_mem_db?mode=memory&cache=shared");

Expand All @@ -804,10 +804,10 @@ mod tests {

#[actix_rt::test]
async fn copy_to_existing_ignore_mode() -> MbtResult<()> {
let src_file = PathBuf::from("../tests/fixtures/files/world_cities_modified.mbtiles");
let src_file = PathBuf::from("../tests/fixtures/mbtiles/world_cities_modified.mbtiles");

// Copy the dst file to an in-memory DB
let dst_file = PathBuf::from("../tests/fixtures/files/world_cities.mbtiles");
let dst_file = PathBuf::from("../tests/fixtures/mbtiles/world_cities.mbtiles");
let dst =
PathBuf::from("file:copy_to_existing_ignore_mode_mem_db?mode=memory&cache=shared");

Expand Down Expand Up @@ -858,19 +858,19 @@ mod tests {
#[actix_rt::test]
async fn apply_flat_diff_file() -> MbtResult<()> {
// Copy the src file to an in-memory DB
let src_file = PathBuf::from("../tests/fixtures/files/world_cities.mbtiles");
let src_file = PathBuf::from("../tests/fixtures/mbtiles/world_cities.mbtiles");
let src = PathBuf::from("file:apply_flat_diff_file_mem_db?mode=memory&cache=shared");

let mut src_conn = TileCopierOptions::new(src_file.clone(), src.clone())
.run()
.await?;

// Apply diff to the src data in in-memory DB
let diff_file = PathBuf::from("../tests/fixtures/files/world_cities_diff.mbtiles");
let diff_file = PathBuf::from("../tests/fixtures/mbtiles/world_cities_diff.mbtiles");
apply_mbtiles_diff(src, diff_file).await?;

// Verify the data is the same as the file the diff was generated from
let path = "../tests/fixtures/files/world_cities_modified.mbtiles";
let path = "../tests/fixtures/mbtiles/world_cities_modified.mbtiles";
attach_other_db(&mut src_conn, path).await?;

assert!(
Expand All @@ -886,19 +886,19 @@ mod tests {
#[actix_rt::test]
async fn apply_normalized_diff_file() -> MbtResult<()> {
// Copy the src file to an in-memory DB
let src_file = PathBuf::from("../tests/fixtures/files/geography-class-jpg.mbtiles");
let src_file = PathBuf::from("../tests/fixtures/mbtiles/geography-class-jpg.mbtiles");
let src = PathBuf::from("file:apply_normalized_diff_file_mem_db?mode=memory&cache=shared");

let mut src_conn = TileCopierOptions::new(src_file.clone(), src.clone())
.run()
.await?;

// Apply diff to the src data in in-memory DB
let diff_file = PathBuf::from("../tests/fixtures/files/geography-class-jpg-diff.mbtiles");
let diff_file = PathBuf::from("../tests/fixtures/mbtiles/geography-class-jpg-diff.mbtiles");
apply_mbtiles_diff(src, diff_file).await?;

// Verify the data is the same as the file the diff was generated from
let path = "../tests/fixtures/files/geography-class-jpg-modified.mbtiles";
let path = "../tests/fixtures/mbtiles/geography-class-jpg-modified.mbtiles";
attach_other_db(&mut src_conn, path).await?;

assert!(
Expand Down
2 changes: 1 addition & 1 deletion tests/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ postgres:

pmtiles:
sources:
pmt: tests/fixtures/files/stamen_toner__raster_CC-BY+ODbL_z3.pmtiles
pmt: tests/fixtures/pmtiles/stamen_toner__raster_CC-BY+ODbL_z3.pmtiles

sprites:
paths: tests/fixtures/sprites/src1
Expand Down
6 changes: 0 additions & 6 deletions tests/expected/auto/catalog_auto.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
"content_type": "application/x-protobuf",
"description": "autodetect.auto_table.geom"
},
"bad_hash": {
"content_type": "application/x-protobuf",
"content_encoding": "gzip",
"name": "Major cities from Natural Earth data",
"description": "Major cities from Natural Earth data"
},
"bigint_table": {
"content_type": "application/x-protobuf",
"description": "autodetect.bigint_table.geom"
Expand Down
39 changes: 21 additions & 18 deletions tests/expected/generated_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,27 @@ postgres:
schema: public
function: function_zxy_row_key
pmtiles:
paths: tests/fixtures/files
paths:
- tests/fixtures/mbtiles
- tests/fixtures/pmtiles
sources:
png: tests/fixtures/files/png.pmtiles
stamen_toner__raster_CC-BY-ODbL_z3: tests/fixtures/files/stamen_toner__raster_CC-BY+ODbL_z3.pmtiles
webp2: tests/fixtures/files/webp2.pmtiles
png: tests/fixtures/pmtiles/png.pmtiles
stamen_toner__raster_CC-BY-ODbL_z3: tests/fixtures/pmtiles/stamen_toner__raster_CC-BY+ODbL_z3.pmtiles
webp2: tests/fixtures/pmtiles/webp2.pmtiles
mbtiles:
paths: tests/fixtures/files
paths:
- tests/fixtures/mbtiles
- tests/fixtures/pmtiles
sources:
bad_hash: tests/fixtures/files/bad_hash.mbtiles
geography-class-jpg: tests/fixtures/files/geography-class-jpg.mbtiles
geography-class-jpg-diff: tests/fixtures/files/geography-class-jpg-diff.mbtiles
geography-class-jpg-modified: tests/fixtures/files/geography-class-jpg-modified.mbtiles
geography-class-png: tests/fixtures/files/geography-class-png.mbtiles
geography-class-png-no-bounds: tests/fixtures/files/geography-class-png-no-bounds.mbtiles
json: tests/fixtures/files/json.mbtiles
uncompressed_mvt: tests/fixtures/files/uncompressed_mvt.mbtiles
webp: tests/fixtures/files/webp.mbtiles
world_cities: tests/fixtures/files/world_cities.mbtiles
world_cities_diff: tests/fixtures/files/world_cities_diff.mbtiles
world_cities_modified: tests/fixtures/files/world_cities_modified.mbtiles
zoomed_world_cities: tests/fixtures/files/zoomed_world_cities.mbtiles
geography-class-jpg: tests/fixtures/mbtiles/geography-class-jpg.mbtiles
geography-class-jpg-diff: tests/fixtures/mbtiles/geography-class-jpg-diff.mbtiles
geography-class-jpg-modified: tests/fixtures/mbtiles/geography-class-jpg-modified.mbtiles
geography-class-png: tests/fixtures/mbtiles/geography-class-png.mbtiles
geography-class-png-no-bounds: tests/fixtures/mbtiles/geography-class-png-no-bounds.mbtiles
json: tests/fixtures/mbtiles/json.mbtiles
uncompressed_mvt: tests/fixtures/mbtiles/uncompressed_mvt.mbtiles
webp: tests/fixtures/mbtiles/webp.mbtiles
world_cities: tests/fixtures/mbtiles/world_cities.mbtiles
world_cities_diff: tests/fixtures/mbtiles/world_cities_diff.mbtiles
world_cities_modified: tests/fixtures/mbtiles/world_cities_modified.mbtiles
zoomed_world_cities: tests/fixtures/mbtiles/zoomed_world_cities.mbtiles
2 changes: 1 addition & 1 deletion tests/expected/given_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ postgres:
- 90.0
pmtiles:
sources:
pmt: tests/fixtures/files/stamen_toner__raster_CC-BY+ODbL_z3.pmtiles
pmt: tests/fixtures/pmtiles/stamen_toner__raster_CC-BY+ODbL_z3.pmtiles
sprites:
paths: tests/fixtures/sprites/src1
sources:
Expand Down
1 change: 1 addition & 0 deletions tests/expected/mbtiles/copy_diff2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[INFO ] Creating new metadata value agg_tiles_hash = D41D8CD98F00B204E9800998ECF8427E in tests/temp/world_cities_diff_modified.mbtiles
6 changes: 3 additions & 3 deletions tests/expected/mbtiles/validate-ok.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[INFO ] Quick integrity check passed for ./tests/fixtures/files/zoomed_world_cities.mbtiles
[INFO ] All tile hashes are valid for ./tests/fixtures/files/zoomed_world_cities.mbtiles
[INFO ] The agg_tiles_hashes=D4E1030D57751A0B45A28A71267E46B8 has been verified for ./tests/fixtures/files/zoomed_world_cities.mbtiles
[INFO ] Quick integrity check passed for ./tests/fixtures/mbtiles/zoomed_world_cities.mbtiles
[INFO ] All tile hashes are valid for ./tests/fixtures/mbtiles/zoomed_world_cities.mbtiles
[INFO ] The agg_tiles_hashes=D4E1030D57751A0B45A28A71267E46B8 has been verified for ./tests/fixtures/mbtiles/zoomed_world_cities.mbtiles
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions tests/mb_server_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ fn test_get(path: &str) -> TestRequest {
const CONFIG: &str = indoc! {"
mbtiles:
sources:
m_json: tests/fixtures/files/json.mbtiles
m_mvt: tests/fixtures/files/world_cities.mbtiles
m_raw_mvt: tests/fixtures/files/uncompressed_mvt.mbtiles
m_webp: tests/fixtures/files/webp.mbtiles
m_json: tests/fixtures/mbtiles/json.mbtiles
m_mvt: tests/fixtures/mbtiles/world_cities.mbtiles
m_raw_mvt: tests/fixtures/mbtiles/uncompressed_mvt.mbtiles
m_webp: tests/fixtures/mbtiles/webp.mbtiles
"};

#[actix_rt::test]
Expand Down
Loading

0 comments on commit c00f12f

Please sign in to comment.