Skip to content

Commit

Permalink
Add a reduced test case for test_martin_675 (#32)
Browse files Browse the repository at this point in the history
The file contains a leaf directory and the faulty code fails to
descend into it when locating a tile by id.
  • Loading branch information
jleedev authored Feb 5, 2024
1 parent b5a9f82 commit 245911e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Binary file added fixtures/leaf.pmtiles
Binary file not shown.
19 changes: 13 additions & 6 deletions src/async_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,22 @@ mod tests {
}

#[tokio::test]
#[ignore = "This test requires a 200mb file to be downloaded. See https://github.com/maplibre/martin/issues/675"]
async fn test_martin_675() {
// the file was manually placed here from the test because it is 200mb
// see also https://github.com/protomaps/PMTiles/issues/182 - once the file is shrunk somehow?
let backend = MmapBackend::try_from("fixtures/tiles.pmtiles")
let backend = MmapBackend::try_from("fixtures/leaf.pmtiles")
.await
.unwrap();
let tiles = AsyncPmTilesReader::try_from_source(backend).await.unwrap();
let tile = tiles.get_tile(7, 35, 50).await;
assert!(tile.is_some());
// Verify that the test case does contain a leaf directory
assert_ne!(0, tiles.get_header().leaf_length);
for (contents, z, x, y) in [
(b"0", 0, 0, 0),
(b"1", 1, 0, 0),
(b"2", 1, 0, 1),
(b"3", 1, 1, 1),
(b"4", 1, 1, 0),
] {
let tile = tiles.get_tile(z, x, y).await.unwrap();
assert_eq!(tile, &contents[..]);
}
}
}

0 comments on commit 245911e

Please sign in to comment.