Skip to content

Commit

Permalink
Add integ tests for the ping feature
Browse files Browse the repository at this point in the history
TODO: get the exit code test to pass
  • Loading branch information
offbyone committed Jun 18, 2024
1 parent 7332a9f commit f6dfa27
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/features/basic_commands.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions tests/features/steps/basic_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f6dfa27

Please sign in to comment.