From f6dfa279849310e545dfa00b51fb1a4de9ab9b18 Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Tue, 18 Jun 2024 09:17:08 -0700 Subject: [PATCH] Add integ tests for the ping feature TODO: get the exit code test to pass --- tests/features/basic_commands.feature | 8 ++++++++ tests/features/steps/basic_commands.py | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/tests/features/basic_commands.feature b/tests/features/basic_commands.feature index ee497b98a..2eb2239fd 100644 --- a/tests/features/basic_commands.feature +++ b/tests/features/basic_commands.feature @@ -51,6 +51,14 @@ Feature: run the cli, When we list databases then we see list of databases + Scenario: ping databases + When we ping the database + then we get a pong response + + Scenario: ping databases + When we ping the database + then we exit with 0 + Scenario: run the cli with --username When we launch dbcli using --username and we send "\?" command diff --git a/tests/features/steps/basic_commands.py b/tests/features/steps/basic_commands.py index 687bdc0a9..77688cfce 100644 --- a/tests/features/steps/basic_commands.py +++ b/tests/features/steps/basic_commands.py @@ -26,6 +26,23 @@ def step_see_list_databases(context): context.cmd_output = None +@when("we ping the database") +def step_ping_database(context): + cmd = ["pgcli", "--ping"] + context.cmd_output = subprocess.check_output(cmd, cwd=context.package_root) + + +@then("we get a pong response") +def step_get_pong_response(context): + assert context.cmd_output.strip() == b"PONG", f"Output was {context.cmd_output}" + + +@then("we exit with 0") +def step_exit_with_0(context): + context.cli.close() + assert context.cli.exitstatus == 0, f"Exit code was {context.cli.exitstatus}" + + @when("we run dbcli") def step_run_cli(context): wrappers.run_cli(context)