Skip to content

Commit 38cd4ba

Browse files
committed
Fix: freshdb fixture db connection environment variables
1 parent 42349de commit 38cd4ba

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

yhttp/dev/fixtures.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@ def _make_temp_directory(**kw):
5353

5454

5555
@pytest.fixture
56-
def freshdb():
56+
def freshdb(cicd):
5757
""" Creates a fresh database for each test.
5858
5959
Default configuration is using peer authentication method on
6060
Postgresql's Unix Domain Socket.
6161
"""
6262
from yhttp.ext.dbmanager import PostgresqlManager
6363

64-
host = os.environ.get('YHTTPDEV_DB_HOST', '')
65-
user = os.environ.get('YHTTPDEV_DB_USER', '')
66-
password = os.environ.get('YHTTPDEV_DB_PASS', '')
64+
host = os.environ.get('YHTTP_DB_DEFAULT_HOST', 'localhost' if cicd else '')
65+
user = os.environ.get('YHTTP_DB_DEFAULT_USER', 'postgres' if cicd else '')
66+
pass_ = os.environ.get('YHTTP_DB_DEFAULT_PASS', 'postgres' if cicd else '')
6767

6868
dbname = f'freshdb_{datetime.datetime.now():%Y%m%d%H%M%S}'
69-
dbmanager = PostgresqlManager(host, 'postgres', user, password)
69+
dbmanager = PostgresqlManager(host, 'postgres', user, pass_)
7070
dbmanager.create(dbname, dropifexists=True)
71-
freshurl = f'postgres://{user}:{password}@{host}/{dbname}'
71+
freshurl = f'postgres://{user}:{pass_}@{host}/{dbname}'
7272
yield freshurl
7373
dbmanager.dropifexists(dbname)
7474

0 commit comments

Comments
 (0)