Make POSTGIS_VERSION detection automatic

This commit is contained in:
Raul Marin 2018-06-11 14:47:39 +02:00
parent 462d25bebc
commit 9bbbe9e7c1
9 changed files with 23 additions and 9 deletions

View File

@ -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

View File

@ -6,4 +6,4 @@ npm install -g yarn@0.27.5
yarn
# run tests
POSTGIS_VERSION=2.4 npm test
npm test

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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));
}

View File

@ -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;

View File

@ -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

View File

@ -70,6 +70,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..."