summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith.r@gmail.com>2019-05-14 00:01:20 -0700
committerAmjith Ramanujam <amjith.r@gmail.com>2019-05-14 00:01:20 -0700
commit004f62e714ee64e908431e357009ed7bdf4eb85f (patch)
tree0840118c431cd82df1350453fd91c28777985ef5 /tests
parenta45c67acf0f8e46c88d8e02daaae37b2ac48d031 (diff)
Add some behavioral tests for command line options.
Diffstat (limited to 'tests')
-rw-r--r--tests/features/basic_commands.feature23
-rw-r--r--tests/features/steps/basic_commands.py19
-rw-r--r--tests/features/steps/wrappers.py5
3 files changed, 44 insertions, 3 deletions
diff --git a/tests/features/basic_commands.feature b/tests/features/basic_commands.feature
index 8c9ce437..b3c546a2 100644
--- a/tests/features/basic_commands.feature
+++ b/tests/features/basic_commands.feature
@@ -21,4 +21,25 @@ Feature: run the cli,
Scenario: list databases
When we list databases
then we see list of databases
-
+
+ Scenario: run the cli with --username
+ When we launch dbcli using --username
+ and we send "\?" command
+ then we see help output
+
+ Scenario: run the cli with --user
+ When we launch dbcli using --user
+ and we send "\?" command
+ then we see help output
+
+ Scenario: run the cli with --port
+ When we launch dbcli using --port
+ and we send "\?" command
+ then we see help output
+
+ Scenario: run the cli with --password
+ When we launch dbcli using --password
+ then we send password
+ and we see dbcli prompt
+ when we send "\?" command
+ then we see help output
diff --git a/tests/features/steps/basic_commands.py b/tests/features/steps/basic_commands.py
index ab46089e..1f88780a 100644
--- a/tests/features/steps/basic_commands.py
+++ b/tests/features/steps/basic_commands.py
@@ -6,6 +6,7 @@ This string is used to call the step in "*.feature" file.
"""
from __future__ import unicode_literals, print_function
+import sys
import pexpect
import subprocess
import tempfile
@@ -32,6 +33,19 @@ def step_see_list_databases(context):
def step_run_cli(context):
wrappers.run_cli(context)
+@when('we launch dbcli using {arg}')
+def step_run_cli_using_arg(context, arg):
+ prompt_check = False
+ if arg == '--username':
+ arg = '--username={}'.format(context.conf['user'])
+ if arg == '--user':
+ arg = '--user={}'.format(context.conf['user'])
+ if arg == '--port':
+ arg = '--port={}'.format(context.conf['port'])
+ if arg == '--password':
+ arg = '--password'
+ prompt_check = False
+ wrappers.run_cli(context, run_args=[arg], prompt_check=prompt_check)
@when('we wait for prompt')
def step_wait_prompt(context):
@@ -98,3 +112,8 @@ def step_confirm_destructive_command(context):
wrappers.expect_exact(
context, 'You\'re about to run a destructive command.\r\nDo you want to proceed? (y/n):', timeout=2)
context.cli.sendline('y')
+
+@then(u'we send password')
+def step_send_password(context):
+ wrappers.expect_exact(context, 'Password for postgres:', timeout=5)
+ context.cli.sendline(context.conf['pass'] or 'DOES NOT MATTER')
diff --git a/tests/features/steps/wrappers.py b/tests/features/steps/wrappers.py
index 66dd483c..11809b30 100644
--- a/tests/features/steps/wrappers.py
+++ b/tests/features/steps/wrappers.py
@@ -49,7 +49,7 @@ def expect_pager(context, expected, timeout):
context.conf['pager_boundary'], expected), timeout=timeout)
-def run_cli(context, run_args=None):
+def run_cli(context, run_args=None, prompt_check=True):
"""Run the process using pexpect."""
run_args = run_args or []
cli_cmd = context.conf.get('cli_command')
@@ -61,7 +61,8 @@ def run_cli(context, run_args=None):
context.exit_sent = False
context.currentdb = context.conf['dbname']
context.cli.sendline('\pset pager always')
- wait_prompt(context)
+ if prompt_check:
+ wait_prompt(context)
def wait_prompt(context):