mirror of
https://gitlab.com/KKlochko/tui-rsync.git
synced 2026-08-20 05:37:43 +00:00
Add the E2E tests for the CLI interface.
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
Feature: Creating a backup plan with the CLI
|
||||||
|
|
||||||
|
@fixture.injector
|
||||||
|
@fixture.in_memory_database
|
||||||
|
@fixture.cli
|
||||||
|
Scenario Outline: Create an new unique backup plan with the CLI
|
||||||
|
Given the CLI arguments are "<arguments>"
|
||||||
|
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 |
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
Feature: Creating the source
|
Feature: Creating a backup plan
|
||||||
|
|
||||||
@fixture.injector
|
@fixture.injector
|
||||||
@fixture.in_memory_database
|
@fixture.in_memory_database
|
||||||
|
|||||||
@@ -1,10 +1,24 @@
|
|||||||
from behave import fixture, use_fixture
|
from behave import fixture, use_fixture
|
||||||
from injector import Injector
|
from injector import Injector
|
||||||
|
from typer.testing import CliRunner
|
||||||
|
|
||||||
from tui_rsync.core.components.backup_plan.application.repository.backup_plan_repository import BackupPlanRepository
|
from tui_rsync.core.components.backup_plan.application.repository.backup_plan_repository import BackupPlanRepository
|
||||||
from tui_rsync.core.components.backup_plan.application.services.backup_plan_service import BackupPlanService
|
from tui_rsync.core.components.backup_plan.application.services.backup_plan_service import BackupPlanService
|
||||||
from tui_rsync.infrastructure.configuration import TestingConfiguration, CurrentConfiguration
|
from tui_rsync.infrastructure.configuration import TestingConfiguration, CurrentConfiguration
|
||||||
from tui_rsync.infrastructure.orm import InMemoryDatabaseManager
|
from tui_rsync.infrastructure.orm import InMemoryDatabaseManager
|
||||||
|
from tui_rsync.user_interface.cli.cli import cli_app
|
||||||
|
|
||||||
|
|
||||||
|
@fixture
|
||||||
|
def setup_cli_runner(context):
|
||||||
|
context.cli_runner = CliRunner()
|
||||||
|
yield context.cli_runner
|
||||||
|
|
||||||
|
|
||||||
|
@fixture
|
||||||
|
def setup_cli_app(context):
|
||||||
|
context.cli_app = cli_app
|
||||||
|
yield context.cli_app
|
||||||
|
|
||||||
|
|
||||||
@fixture
|
@fixture
|
||||||
@@ -33,3 +47,6 @@ def before_tag(context, tag):
|
|||||||
use_fixture(setup_in_memory_database_manager, context)
|
use_fixture(setup_in_memory_database_manager, context)
|
||||||
if tag == "fixture.backup_plan_service":
|
if tag == "fixture.backup_plan_service":
|
||||||
use_fixture(setup_backup_plan_service, context)
|
use_fixture(setup_backup_plan_service, context)
|
||||||
|
if tag == "fixture.cli":
|
||||||
|
use_fixture(setup_cli_app, context)
|
||||||
|
use_fixture(setup_cli_runner, context)
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
from behave import given, when, then
|
||||||
|
|
||||||
|
|
||||||
|
@given('the CLI arguments are "{arguments}"')
|
||||||
|
def given_cli_arguments(context, arguments):
|
||||||
|
print(f"{arguments}")
|
||||||
|
context.arguments = arguments.split()
|
||||||
|
print(f"{context.arguments}")
|
||||||
|
|
||||||
|
|
||||||
|
@when('I run the CLI')
|
||||||
|
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 output contains "{string}"')
|
||||||
|
def then_cli_output_contains(context, string):
|
||||||
|
assert string in context.cli_result.stdout
|
||||||
|
|
||||||
|
|
||||||
|
@then('the CLI contains the error: "{string}"')
|
||||||
|
def then_cli_output_contains_error(context, string):
|
||||||
|
assert string in context.cli_result.stdout
|
||||||
|
|
||||||
Reference in New Issue
Block a user