Skip to content

Commit

Permalink
Fix TODO, optionally use POSTGRES_USER, POSTGRES_HOST POSTGRES_PASSWO…
Browse files Browse the repository at this point in the history
…RD from environment
  • Loading branch information
meeuw committed Aug 18, 2017
1 parent 1e77eab commit 5ab0dbf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Bug Fixes:
* Fix the way we get host when using DSN (issue #765) (Thanks: `François Pietka`_)
* Add missing keyword COLUMN after DROP (issue #769) (Thanks: `François Pietka`_)
* Don't include arguments in function suggestions for backslash commands (Thanks: `Joakim Koljonen`_)
* Optionally use POSTGRES_USER, POSTGRES_HOST POSTGRES_PASSWORD from environment (Thanks: `Dick Marinus`_)

1.7.0
=====
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from utils import (POSTGRES_HOST, POSTGRES_USER, create_db, db_connection,
from utils import (POSTGRES_HOST, POSTGRES_USER, POSTGRES_PASSWORD, create_db, db_connection,
drop_tables)
import pgcli.pgexecute

Expand All @@ -23,7 +23,7 @@ def cursor(connection):
@pytest.fixture
def executor(connection):
return pgcli.pgexecute.PGExecute(database='_test_db', user=POSTGRES_USER,
host=POSTGRES_HOST, password=None, port=None, dsn=None)
host=POSTGRES_HOST, password=POSTGRES_PASSWORD, port=None, dsn=None)


@pytest.fixture
Expand Down
6 changes: 4 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import psycopg2.extras
from pgcli.main import format_output, OutputSettings
from pgcli.pgexecute import register_json_typecasters
from os import getenv

# TODO: should this be somehow be divined from environment?
POSTGRES_USER, POSTGRES_HOST = 'postgres', 'localhost'
POSTGRES_USER = getenv('PGUSER', 'postgres')
POSTGRES_HOST = getenv('PGHOST', 'localhost')
POSTGRES_PASSWORD = getenv('PGPASSWORD', '')


def db_connection(dbname=None):
Expand Down

0 comments on commit 5ab0dbf

Please sign in to comment.