Skip to content

Commit 768bab8

Browse files
committed
Merge pull request #2470 from SebDieBln/postgrestest
[postgresprovider] make the test more portable
2 parents 526b8fc + ebf132e commit 768bab8

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

ci/travis/linux/before_script.sh

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
printf "[qgis_test]\nhost=localhost\ndbname=qgis_test\nuser=postgres" > ~/.pg_service.conf
22
psql -c 'CREATE DATABASE qgis_test;' -U postgres
3-
psql -c 'CREATE EXTENSION postgis;' -U postgres -d qgis_test
43
psql -f $TRAVIS_BUILD_DIR/tests/testdata/provider/testdata.sql -U postgres -d qgis_test
54

tests/README.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,23 @@ Advanced configuration
3636

3737
### Postgres
3838

39+
Make sure that you have enabled building of postgres test in CMake.
40+
`cmake -DENABLE_PGTEST=ON ..`
41+
3942
To test the postgres provider you will need to have a database available to
40-
which the postgres provider can connect. This will need to have postgis support
41-
enabled and be available as a service called `qgis_test` on the machine you run
42-
the tests on.
43+
which the postgres provider can connect. The server will need to have postgis
44+
support enabled.
45+
By default the test uses the following connection options:
46+
dbname='qgis_test'
47+
host=localhost
48+
port=5432
49+
user='postgres'
50+
password='postgres'
51+
52+
If this does not match your setup you can set the environment variable
53+
QGIS_PGTEST_DB to the desired connection string.
54+
55+
Please note that the database needs to be initialized using the sql-script
56+
tests/testdata/provider/testdata.sql
57+
It takes care of activating postgis for the test database and
58+
creates some tables containing test data.

tests/testdata/provider/testdata.sql

+7-7
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ CREATE TABLE qgis_test."someData" (
4747
-- Data for Name: someData; Type: TABLE DATA; Schema: qgis_test; Owner: postgres
4848
--
4949

50-
COPY qgis_test."someData" (pk, cnt, name, geom) FROM stdin;
51-
5 -200 \N 0101000020E61000001D5A643BDFC751C01F85EB51B88E5340
52-
3 300 Pear \N
53-
1 100 Orange 0101000020E61000006891ED7C3F9551C085EB51B81E955040
54-
2 200 Apple 0101000020E6100000CDCCCCCCCC0C51C03333333333B35140
55-
4 400 Honey 0101000020E610000014AE47E17A5450C03333333333935340
56-
\.
50+
INSERT INTO qgis_test."someData" (pk, cnt, name, geom) VALUES
51+
(5, -200, NULL, '0101000020E61000001D5A643BDFC751C01F85EB51B88E5340'),
52+
(3, 300, 'Pear', NULL),
53+
(1, 100, 'Orange', '0101000020E61000006891ED7C3F9551C085EB51B81E955040'),
54+
(2, 200, 'Apple', '0101000020E6100000CDCCCCCCCC0C51C03333333333B35140'),
55+
(4, 400, 'Honey', '0101000020E610000014AE47E17A5450C03333333333935340')
56+
;
5757

5858

5959
--

0 commit comments

Comments
 (0)