Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Do not hard-code database connection parameters
Rely on libpq defaults instead (overridable via environment)
  • Loading branch information
Sandro Santilli committed Feb 15, 2016
1 parent 942c5e5 commit ab580fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions tests/README.md
Expand Up @@ -42,17 +42,19 @@ Make sure that you have enabled building of postgres test in CMake.
To test the postgres provider you will need to have a database available to
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'

By default the test uses the following connection string:

dbname=qgis_test

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

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.

tests/testdata/provider/testdata_pg*.sql

They take care of activating postgis for the test database and
create some tables containing test data.
2 changes: 1 addition & 1 deletion tests/src/python/test_provider_postgres.py
Expand Up @@ -33,7 +33,7 @@ class TestPyQgsPostgresProvider(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
cls.dbconn = u'dbname=\'qgis_test\' host=localhost port=5432 user=\'postgres\' password=\'postgres\''
cls.dbconn = u'dbname=\'qgis_test\''
if 'QGIS_PGTEST_DB' in os.environ:
cls.dbconn = os.environ['QGIS_PGTEST_DB']
# Create test layers
Expand Down

0 comments on commit ab580fb

Please sign in to comment.