Files
watermaps/deploy/scripts/tests/route-smoke-sources.test.sh
T
BuTzZ 0211453281
Test and publish container images / test (push) Successful in 2m35s
Test and publish container images / publish (push) Successful in 1m53s
Accept combined production routing sources
2026-07-29 14:26:33 +02:00

54 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -Eeuo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
COMMON_SH="$ROOT_DIR/deploy/scripts/common.sh"
TEST_DIR="$(mktemp -d)"
trap 'rm -rf "$TEST_DIR"' EXIT
VALIDATOR_JS="$TEST_DIR/route-source-validator.mjs"
awk '
/ROUTE_SOURCE_VALIDATOR_START/ { capture = 1; next }
/ROUTE_SOURCE_VALIDATOR_END/ { capture = 0 }
capture {
sub(/^ /, "")
print
}
' "$COMMON_SH" >"$VALIDATOR_JS"
[[ -s "$VALIDATOR_JS" ]] || {
printf 'Der Datenquellen-Validator konnte nicht aus common.sh gelesen werden.\n' >&2
exit 1
}
printf '%s\n' \
'const assertSourceValidity = (expected, dataSources, description) => {' \
' const actual = hasExpectedRouteSources(dataSources);' \
' if (actual !== expected) {' \
' console.error(`${description}: erwartet ${expected}, erhalten ${actual}`);' \
' process.exit(1);' \
' }' \
'};' \
'const bbox = "7.037-53.192-7.623-53.615";' \
'const localSource = `fairway-graph:local-geofabrik-${bbox}`;' \
'const combinedSource = `fairway-graph:combined-postgis-${bbox}+local-geofabrik-${bbox}`;' \
'assertSourceValidity(true, [localSource, "local-geofabrik-germany+netherlands"], "lokaler Index");' \
'assertSourceValidity(true, [combinedSource, "postgis-osm"], "kombinierter Produktionsgraph");' \
'assertSourceValidity(true, [combinedSource, "local-geofabrik-germany+netherlands"], "kombinierter Graph mit lokalen Kanten");' \
'assertSourceValidity(true, [combinedSource, "postgis-osm", "local-geofabrik-germany+netherlands"], "kombinierter Graph mit beiden Kantenquellen");' \
'assertSourceValidity(false, ["local-geofabrik-germany+netherlands"], "lokale Kante ohne Graph");' \
'assertSourceValidity(false, [combinedSource], "kombinierter Graph ohne Kantenquelle");' \
'assertSourceValidity(false, [`fairway-graph:combined-postgis-${bbox}+local-geofabrik-7.000-53.000-8.000-54.000`, "postgis-osm"], "abweichende Ausschnitte");' \
'assertSourceValidity(false, ["fairway-graph:combined-postgis-anything+local-geofabrik-anything", "postgis-osm"], "ungültiger Ausschnitt");' \
'assertSourceValidity(false, ["postgis-osm"], "fehlender lokaler Graph");' \
'assertSourceValidity(false, [combinedSource, "postgis-osm", "osm-overpass"], "unbekannte Kantenquelle");' \
'assertSourceValidity(false, [`${combinedSource}+osm-overpass-live`, "postgis-osm"], "zusätzlicher Live-Graph");' \
'assertSourceValidity(false, [combinedSource, "postgis-osm", "postgis-osm"], "doppelte Quelle");' \
'assertSourceValidity(false, [combinedSource, 42], "Nicht-String-Quelle");' \
'assertSourceValidity(false, null, "fehlende Quellenliste");' \
'console.log("Routing-Smoke-Test-Datenquellen: OK");' \
>>"$VALIDATOR_JS"
node "$VALIDATOR_JS"