diff options
author | Dick Marinus <dick@mrns.nl> | 2018-04-27 09:52:59 +0200 |
---|---|---|
committer | Dick Marinus <dick@mrns.nl> | 2018-04-27 09:52:59 +0200 |
commit | 21bc10086cfcb110c80c9f329260a134e2200725 (patch) | |
tree | 65aae304823c664371e8699d28a205be714d55fc /tests/features | |
parent | 242577e69434ab988e721f8b5d555dedaa53da3d (diff) |
add test to check application_name
Diffstat (limited to 'tests/features')
-rw-r--r-- | tests/features/basic_commands.feature | 4 | ||||
-rw-r--r-- | tests/features/steps/basic_commands.py | 24 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/features/basic_commands.feature b/tests/features/basic_commands.feature index 249a68e6..a12e8992 100644 --- a/tests/features/basic_commands.feature +++ b/tests/features/basic_commands.feature @@ -10,6 +10,10 @@ Feature: run the cli, When we send source command then we see help output + Scenario: check our application_name + When we run query to check application_name + then we see found + Scenario: run the cli and exit When we send "ctrl + d" then dbcli exits diff --git a/tests/features/steps/basic_commands.py b/tests/features/steps/basic_commands.py index 30525906..d8d603e2 100644 --- a/tests/features/steps/basic_commands.py +++ b/tests/features/steps/basic_commands.py @@ -10,6 +10,7 @@ import tempfile from behave import when import wrappers +from textwrap import dedent @when('we run dbcli') @@ -47,3 +48,26 @@ def step_send_source_command(context): context.cli.sendline('\i {0}'.format(f.name)) wrappers.expect_exact( context, context.conf['pager_boundary'] + '\r\n', timeout=5) + + +@when(u'we run query to check application_name') +def step_check_application_name(context): + context.cli.sendline( + "SELECT 'found' FROM pg_stat_activity WHERE application_name = 'pgcli' HAVING COUNT(*) > 0;" + ) + + +@then(u'we see found') +def step_see_found(context): + wrappers.expect_exact( + context, + context.conf['pager_boundary'] + '\r' + dedent(''' + +------------+\r + | ?column? |\r + |------------|\r + | found |\r + +------------+\r + SELECT 1\r + ''') + context.conf['pager_boundary'], + timeout=5 + ) |