From 5e606b0e83e90d9ed3efcb2f980d8769f42d6a5b Mon Sep 17 00:00:00 2001 From: KKlochko Date: Sat, 25 Jan 2025 21:43:27 +0200 Subject: [PATCH] Update to step to test the result of CLI execution. --- features/backup_plan_cli_add.feature | 2 +- features/backup_plan_cli_delete.feature | 24 +++++------------------- features/steps/cli_runner_steps.py | 15 +++++++-------- 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/features/backup_plan_cli_add.feature b/features/backup_plan_cli_add.feature index b8272f9..8681e70 100644 --- a/features/backup_plan_cli_add.feature +++ b/features/backup_plan_cli_add.feature @@ -6,7 +6,7 @@ Feature: Creating a backup plan with the CLI Scenario Outline: Create an new unique backup plan with the CLI Given the CLI arguments are "" When I run the CLI - Then the CLI executed successfully + Then the CLI executed with "success" Examples: | arguments | diff --git a/features/backup_plan_cli_delete.feature b/features/backup_plan_cli_delete.feature index 78fe3d6..0674383 100644 --- a/features/backup_plan_cli_delete.feature +++ b/features/backup_plan_cli_delete.feature @@ -1,32 +1,18 @@ Feature: Deleting a backup plan with the CLI - @fixture.injector - @fixture.in_memory_database - @fixture.cli - Scenario Outline: Deleting an existing backup plan with the CLI - Given the CLI arguments are "" - When I run the CLI - Then the CLI executed successfully - - Examples: - | arguments | - | plans add --label my_label --source /mnt -d /mnt2 -d /mnt3 | - | plans add --label label2 --source /mnt -d /mnt2 -d /mnt3 | - - @fixture.injector @fixture.in_memory_database @fixture.seeds @fixture.cli - Scenario Outline: Deleting an non-existing backup plan with the CLI + Scenario Outline: Deleting a backup plan with the CLI Given the CLI arguments are "" And I have a backup plan with id="" When I run the CLI - Then the CLI executed with an error + Then the CLI executed with "" Examples: - | arguments | existing_backup_plan_id | description | - | plans remove one -i 8aa59e7e-dc75-459b-beb5-b710b39be583 | 8aa59e7e-dc75-459b-beb5-b710b39be583 | delete an existing plan | - | plans remove one -i 8aa59e7e-dc75-459b-aeb5-b710b39be583 | 8aa59e7e-dc75-459b-beb5-b710b39be512 | delete a non-existing plan | + | arguments | existing_backup_plan_id | result | description | + | plans remove one -i 8aa59e7e-dc75-459b-beb5-b710b39be583 | 8aa59e7e-dc75-459b-beb5-b710b39be583 | success | delete an existing plan | + | plans remove one -i 8aa59e7e-dc75-459b-aeb5-b710b39be583 | 8aa59e7e-dc75-459b-beb5-b710b39be512 | error | delete a non-existing plan | diff --git a/features/steps/cli_runner_steps.py b/features/steps/cli_runner_steps.py index ef227ac..a8e9267 100644 --- a/features/steps/cli_runner_steps.py +++ b/features/steps/cli_runner_steps.py @@ -13,14 +13,13 @@ def when_run_cli(context): context.cli_result = context.cli_runner.invoke(context.cli_app, context.arguments) -@then('the CLI executed successfully') -def then_cli_executed_successfully(context): - assert context.cli_result.exit_code == 0 - - -@then('the CLI executed with an error') -def then_cli_executed_with_error(context): - assert context.cli_result.exit_code == 0 +@then('the CLI executed with "{result}"') +def then_cli_executed_successfully(context, result): + match result: + case "success": + assert context.cli_result.exit_code == 0 + case "error": + assert context.cli_result.exit_code == 0 @then('the CLI output contains "{string}"')