Skip to content

Commit

Permalink
Merge pull request #2470 from SebDieBln/postgrestest
Browse files Browse the repository at this point in the history
[postgresprovider] make the test more portable
  • Loading branch information
m-kuhn committed Nov 16, 2015
2 parents 526b8fc + ebf132e commit 768bab8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
1 change: 0 additions & 1 deletion ci/travis/linux/before_script.sh
@@ -1,5 +1,4 @@
printf "[qgis_test]\nhost=localhost\ndbname=qgis_test\nuser=postgres" > ~/.pg_service.conf
psql -c 'CREATE DATABASE qgis_test;' -U postgres
psql -c 'CREATE EXTENSION postgis;' -U postgres -d qgis_test
psql -f $TRAVIS_BUILD_DIR/tests/testdata/provider/testdata.sql -U postgres -d qgis_test

22 changes: 19 additions & 3 deletions tests/README.md
Expand Up @@ -36,7 +36,23 @@ Advanced configuration

### Postgres

Make sure that you have enabled building of postgres test in CMake.
`cmake -DENABLE_PGTEST=ON ..`

To test the postgres provider you will need to have a database available to
which the postgres provider can connect. This will need to have postgis support
enabled and be available as a service called `qgis_test` on the machine you run
the tests on.
which the postgres provider can connect. The server will need to have postgis
support enabled.
By default the test uses the following connection options:
dbname='qgis_test'
host=localhost
port=5432
user='postgres'
password='postgres'

If this does not match your setup you can set the environment variable
QGIS_PGTEST_DB to the desired connection string.

Please note that the database needs to be initialized using the sql-script
tests/testdata/provider/testdata.sql
It takes care of activating postgis for the test database and
creates some tables containing test data.
14 changes: 7 additions & 7 deletions tests/testdata/provider/testdata.sql
Expand Up @@ -47,13 +47,13 @@ CREATE TABLE qgis_test."someData" (
-- Data for Name: someData; Type: TABLE DATA; Schema: qgis_test; Owner: postgres
--

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


--
Expand Down

0 comments on commit 768bab8

Please sign in to comment.