diff --git a/run_tests.sh b/run_tests.sh index f26cad6d..b409db83 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -135,7 +135,7 @@ fi echo "Preparing the environment" cd ${BASEDIR}/test/support -sh prepare_db.sh ${PREPARE_DB_OPTS} || die "database preparation failure" +source prepare_db.sh "${PREPARE_DB_OPTS}" || die "database preparation failure" cd - PATH=node_modules/.bin/:$PATH diff --git a/run_tests_docker.sh b/run_tests_docker.sh index 4a6b142a..87b3e2fb 100644 --- a/run_tests_docker.sh +++ b/run_tests_docker.sh @@ -6,4 +6,4 @@ npm install -g yarn@0.27.5 yarn # run tests -POSTGIS_VERSION=2.4 npm test +npm test diff --git a/test/acceptance/aggregation.js b/test/acceptance/aggregation.js index 96401f15..b674bb2d 100644 --- a/test/acceptance/aggregation.js +++ b/test/acceptance/aggregation.js @@ -9,7 +9,7 @@ const suites = [{ usePostGIS: false }]; -if (process.env.POSTGIS_VERSION === '2.4') { +if (process.env.POSTGIS_VERSION >= '20400') { suites.push({ desc: 'mvt (postgis)', usePostGIS: true diff --git a/test/acceptance/buffer-size-format.js b/test/acceptance/buffer-size-format.js index ba8955e7..74e6288c 100644 --- a/test/acceptance/buffer-size-format.js +++ b/test/acceptance/buffer-size-format.js @@ -152,7 +152,7 @@ describe('buffer size per format', function () { }); }); }; - if (process.env.POSTGIS_VERSION === '2.4' && test.format === 'mvt'){ + if (process.env.POSTGIS_VERSION >= '20400' && test.format === 'mvt'){ testFn(true); } testFn(false); @@ -465,7 +465,7 @@ describe('buffer size per format for named maps w/o placeholders', function () { }); }); }; - if (process.env.POSTGIS_VERSION === '2.4' && test.format === 'mvt'){ + if (process.env.POSTGIS_VERSION >= '20400' && test.format === 'mvt'){ testFn(true); } testFn(false); diff --git a/test/acceptance/mvt-regressions.js b/test/acceptance/mvt-regressions.js index 7f5b6658..e8cab0a2 100644 --- a/test/acceptance/mvt-regressions.js +++ b/test/acceptance/mvt-regressions.js @@ -9,7 +9,7 @@ const suites = [{ usePostGIS: false }]; -if (process.env.POSTGIS_VERSION === '2.4') { +if (process.env.POSTGIS_VERSION >= '20400') { suites.push({ desc: 'postgis', usePostGIS: true diff --git a/test/acceptance/mvt.js b/test/acceptance/mvt.js index 065de37a..1d8dd15a 100644 --- a/test/acceptance/mvt.js +++ b/test/acceptance/mvt.js @@ -20,7 +20,7 @@ function createMapConfig(sql = TestClient.SQL.ONE_POINT) { } describe('mvt (mapnik)', mvt(false)); -if (process.env.POSTGIS_VERSION === '2.4') { +if (process.env.POSTGIS_VERSION >= '20400') { describe('mvt (postgis)', mvt(true)); } diff --git a/test/acceptance/user-database-timeout-limit.js b/test/acceptance/user-database-timeout-limit.js index 6e5423e1..d65f6583 100644 --- a/test/acceptance/user-database-timeout-limit.js +++ b/test/acceptance/user-database-timeout-limit.js @@ -440,7 +440,7 @@ describe('user database timeout limit', function () { }); }); - if (process.env.POSTGIS_VERSION === '2.4') { + if (process.env.POSTGIS_VERSION >= '20400') { describe('fetching vector tiles via PostGIS renderer', function() { const usePostGIS = true; const originalUsePostGIS = serverOptions.renderer.mvt.usePostGIS; diff --git a/test/acceptance/vector-layergroup.js b/test/acceptance/vector-layergroup.js index 0778453e..d27fd874 100644 --- a/test/acceptance/vector-layergroup.js +++ b/test/acceptance/vector-layergroup.js @@ -72,7 +72,7 @@ const suites = [{ usePostGIS: false }]; -if (process.env.POSTGIS_VERSION === '2.4') { +if (process.env.POSTGIS_VERSION >= '20400') { suites.push({ desc: 'mvt (postgis)', usePostGIS: true diff --git a/test/support/prepare_db.sh b/test/support/prepare_db.sh index 7df3f3b0..190fa661 100755 --- a/test/support/prepare_db.sh +++ b/test/support/prepare_db.sh @@ -25,6 +25,8 @@ while [ -n "$1" ]; do elif test "$1" = "--no-sql-download"; then DOWNLOAD_SQL_FILES=no shift; continue + else + shift; continue; fi done @@ -70,6 +72,20 @@ echo "PUBLICPASS: ${PUBLICPASS}" echo "TESTUSER: ${TESTUSER}" echo "TESTPASS: ${TESTPASS}" +# Sets the env variable POSTGIS_VERSION as Major * 10000 + Minor * 100 + Patch +# For example, for 2.4.5 ~> 20405 +auto_postgis_version() { + local POSTGIS_STR=$(psql -c "Select default_version from pg_available_extensions WHERE name = 'postgis';" -t); + local pg_version=$(echo $POSTGIS_STR | awk -F '.' '{print $1 * 10000 + $2 * 100 + $3}') + + echo $pg_version +} + +if [ -z "$POSTGIS_VERSION" ]; then + export POSTGIS_VERSION=$(auto_postgis_version) + echo "POSTGIS_VERSION: ${POSTGIS_VERSION}" +fi + if test x"$PREPARE_PGSQL" = xyes; then echo "preparing postgres..."