summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith.r@gmail.com>2019-05-15 23:40:21 -0700
committerAmjith Ramanujam <amjith.r@gmail.com>2019-05-15 23:40:21 -0700
commit5177c9922ebb62ca0b90307c38a13ddc8a574d24 (patch)
tree59954e173abdefd6b3e9d38bd8832f0dff349beb /tests
parent004f62e714ee64e908431e357009ed7bdf4eb85f (diff)
Add a behave test with spaces in password.
Diffstat (limited to 'tests')
-rw-r--r--tests/features/basic_commands.feature6
-rw-r--r--tests/features/environment.py2
-rw-r--r--tests/features/fixture_data/mock_pg_service.conf3
-rw-r--r--tests/features/steps/basic_commands.py3
4 files changed, 14 insertions, 0 deletions
diff --git a/tests/features/basic_commands.feature b/tests/features/basic_commands.feature
index b3c546a2..29e920f2 100644
--- a/tests/features/basic_commands.feature
+++ b/tests/features/basic_commands.feature
@@ -43,3 +43,9 @@ Feature: run the cli,
and we see dbcli prompt
when we send "\?" command
then we see help output
+
+ Scenario: run the cli with dsn and password
+ When we launch dbcli using dsn_password
+ then we send password
+ When we send "\?" command
+ then we see help output
diff --git a/tests/features/environment.py b/tests/features/environment.py
index 25f5c6ba..b21b9010 100644
--- a/tests/features/environment.py
+++ b/tests/features/environment.py
@@ -86,6 +86,7 @@ def before_all(context):
'PGPASSWORD': os.environ.get('PGPASSWORD', None),
'PGPORT': os.environ.get('PGPORT', None),
'XDG_CONFIG_HOME': os.environ.get('XDG_CONFIG_HOME', None),
+ 'PGSERVICEFILE': os.environ.get('PGSERVICEFILE', None),
}
# Set new env vars.
@@ -93,6 +94,7 @@ def before_all(context):
os.environ['PGUSER'] = context.conf['user']
os.environ['PGHOST'] = context.conf['host']
os.environ['PGPORT'] = context.conf['port']
+ os.environ['PGSERVICEFILE'] = os.path.join(fixture_dir, 'mock_pg_service.conf')
if context.conf['pass']:
os.environ['PGPASSWORD'] = context.conf['pass']
diff --git a/tests/features/fixture_data/mock_pg_service.conf b/tests/features/fixture_data/mock_pg_service.conf
new file mode 100644
index 00000000..1c10ee34
--- /dev/null
+++ b/tests/features/fixture_data/mock_pg_service.conf
@@ -0,0 +1,3 @@
+[mock_postgres]
+dbname=postgres
+host=localhost
diff --git a/tests/features/steps/basic_commands.py b/tests/features/steps/basic_commands.py
index 1f88780a..0d193f3c 100644
--- a/tests/features/steps/basic_commands.py
+++ b/tests/features/steps/basic_commands.py
@@ -45,6 +45,9 @@ def step_run_cli_using_arg(context, arg):
if arg == '--password':
arg = '--password'
prompt_check = False
+ if arg == 'dsn_password': # This uses the mock_pg_service.conf file in fixtures folder.
+ arg = 'service=mock_postgres --password'
+ prompt_check = False
wrappers.run_cli(context, run_args=[arg], prompt_check=prompt_check)
@when('we wait for prompt')