summaryrefslogtreecommitdiffstats
path: root/tests/features
diff options
context:
space:
mode:
authorDick Marinus <dick@mrns.nl>2017-04-29 21:35:06 +0200
committerDick Marinus <dick@mrns.nl>2017-04-29 21:35:06 +0200
commit5a604026493ba8dc36eb13306d389cc428994982 (patch)
tree1ef28b4213ca245a78cb27d6c22ac728ac86f3c6 /tests/features
parentfb25e4b923c14fc71bc496b45caf78ec2c5124a7 (diff)
Test using behave the tee command
Diffstat (limited to 'tests/features')
-rw-r--r--tests/features/iocommands.feature11
-rw-r--r--tests/features/steps/iocommands.py37
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/features/iocommands.feature b/tests/features/iocommands.feature
index d043dc2e..4bcdf6e6 100644
--- a/tests/features/iocommands.feature
+++ b/tests/features/iocommands.feature
@@ -8,3 +8,14 @@ Feature: I/O commands
and we exit the editor
then we see dbcli prompt
and we see the sql in prompt
+
+ Scenario: tee output from query
+ When we run dbcli
+ and we wait for prompt
+ and we tee output
+ and we wait for prompt
+ and we query "select 123456"
+ and we wait for prompt
+ and we notee output
+ and we wait for prompt
+ then we see 123456 in tee output
diff --git a/tests/features/steps/iocommands.py b/tests/features/steps/iocommands.py
index 951c1dc6..7393bc4e 100644
--- a/tests/features/steps/iocommands.py
+++ b/tests/features/steps/iocommands.py
@@ -42,3 +42,40 @@ def step_edit_done_sql(context):
# Cleanup the edited file.
if context.editor_file_name and os.path.exists(context.editor_file_name):
os.remove(context.editor_file_name)
+
+
+@when(u'we tee output')
+def step_tee_ouptut(context):
+ context.tee_file_name = [
+ '..',
+ 'tee_file_{0}.sql'.format(context.conf['vi'])
+ ]
+ if os.path.exists(os.path.join(*context.tee_file_name)):
+ os.remove(os.path.join(*context.tee_file_name))
+ context.cli.sendline('\o {0}'.format(context.tee_file_name[1]))
+ wrappers.expect_exact(
+ context, context.conf['pager_boundary'] + '\r\n', timeout=5)
+ wrappers.expect_exact(context, "Writing to file", timeout=5)
+ wrappers.expect_exact(
+ context, context.conf['pager_boundary'] + '\r\n', timeout=5)
+ wrappers.expect_exact(context, "Time", timeout=5)
+
+
+@when(u'we query "select 123456"')
+def step_query_select_123456(context):
+ context.cli.sendline('select 123456')
+
+
+@when(u'we notee output')
+def step_notee_output(context):
+ context.cli.sendline('notee')
+ wrappers.expect_exact(context, "Time", timeout=5)
+
+
+@then(u'we see 123456 in tee output')
+def step_see_123456_in_ouput(context):
+ with open(os.path.join(*context.tee_file_name)) as f:
+ assert '123456' in f.read()
+ if os.path.exists(os.path.join(*context.tee_file_name)):
+ os.remove(os.path.join(*context.tee_file_name))
+ context.atprompt = True