geolith-cli 0.3.2

Rust vector tile generator — OSM + Overture Maps → protomaps PMTiles
Documentation
//! The `geolith dataset` command line: exit codes and the verb surface.

#[test]
fn a_probe_refusal_exits_with_three() {
    let err = geolith_cli::CliError::from(geolith_cli::dataset::error::DatasetError::from(
        geolith_cli::dataset::exit::Exit(3),
    ));
    assert_eq!(geolith_cli::exit_code(&err), 3);
}

#[test]
fn any_other_error_exits_with_one() {
    assert_eq!(
        geolith_cli::exit_code(&geolith_cli::CliError::RoutingNeedsOsmPbf),
        1
    );
}

#[test]
fn the_operator_verbs_parse_with_their_build_id() {
    let command =
        geolith_cli::cli::parse_from(["geolith", "dataset", "keys", "2026-11-20.20261121T2329Z"])
            .expect("dataset keys parses");
    let geolith_cli::cli::Command::Dataset(args) = command else {
        panic!("expected dataset");
    };
    match args.action {
        geolith_cli::cli::DatasetAction::Keys(keys) => {
            assert_eq!(keys.build_id, "2026-11-20.20261121T2329Z");
            assert!(keys.dataset.is_none());
        }
        other => panic!("expected dataset keys, got {other:?}"),
    }
}

#[test]
fn stage_takes_the_engine_build_dir_positionally() {
    let command = geolith_cli::cli::parse_from([
        "geolith",
        "dataset",
        "stage",
        "/tmp/engine/2026-11-20.20261121T2329Z",
    ])
    .expect("dataset stage parses");
    let geolith_cli::cli::Command::Dataset(args) = command else {
        panic!("expected dataset");
    };
    match args.action {
        geolith_cli::cli::DatasetAction::Stage(stage) => {
            assert_eq!(
                stage.engine_build_dir,
                std::path::PathBuf::from("/tmp/engine/2026-11-20.20261121T2329Z")
            );
        }
        other => panic!("expected dataset stage, got {other:?}"),
    }
}

/// `geolith dataset inspect` prints labelled lines, then the report as JSON
/// on the last line; both say what `gdalinfo` says of the fixture.
#[test]
fn dataset_inspect_prints_lines_then_the_json_report() {
    let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
        .join("tests/fixtures/inspect/f32-lzw-stripped.tif");
    let output = std::process::Command::new(env!("CARGO_BIN_EXE_geolith"))
        .args(["dataset", "inspect"])
        .arg(&path)
        .output()
        .expect("run geolith");
    assert!(output.status.success(), "{output:?}");
    let stdout = String::from_utf8(output.stdout).expect("utf-8");
    let (lines, json) = stdout.trim_end().rsplit_once('\n').expect("lines and json");
    let report: serde_json::Value = serde_json::from_str(json).expect("last line is json");
    assert_eq!(report["data_type"], "float32");
    assert_eq!(report["layout"], "stripped 16 rows");
    assert_eq!(report["nodata"], "-9999");
    assert_eq!(report["size"]["height"], 64);
    assert!(report["known_limit"].is_null());
    assert!(lines.lines().any(|l| l == "compression: lzw"), "{lines}");
    assert!(
        lines.lines().any(|l| l == "crs:         EPSG:4326"),
        "{lines}"
    );
}