Skip to content

Commit ab580fb

Browse files
author
Sandro Santilli
committed
Do not hard-code database connection parameters
Rely on libpq defaults instead (overridable via environment)
1 parent 942c5e5 commit ab580fb

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

tests/README.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,19 @@ Make sure that you have enabled building of postgres test in CMake.
4242
To test the postgres provider you will need to have a database available to
4343
which the postgres provider can connect. The server will need to have postgis
4444
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'
45+
46+
By default the test uses the following connection string:
47+
48+
dbname=qgis_test
5149

5250
If this does not match your setup you can set the environment variable
53-
QGIS_PGTEST_DB to the desired connection string.
51+
`QGIS_PGTEST_DB` to the desired connection string, or you can rely
52+
on standard libpq environment variables to tweak host, port user and
53+
password (PGHOST, PGPORT, PGUSER, PGPASSWORD).
5454

5555
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.
56+
57+
tests/testdata/provider/testdata_pg*.sql
58+
59+
They take care of activating postgis for the test database and
60+
create some tables containing test data.

tests/src/python/test_provider_postgres.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TestPyQgsPostgresProvider(unittest.TestCase, ProviderTestCase):
3333
@classmethod
3434
def setUpClass(cls):
3535
"""Run before all tests"""
36-
cls.dbconn = u'dbname=\'qgis_test\' host=localhost port=5432 user=\'postgres\' password=\'postgres\''
36+
cls.dbconn = u'dbname=\'qgis_test\''
3737
if 'QGIS_PGTEST_DB' in os.environ:
3838
cls.dbconn = os.environ['QGIS_PGTEST_DB']
3939
# Create test layers

0 commit comments

Comments
 (0)