Refactor command handling

This now supports usage/help texts
This commit is contained in:
2025-05-18 17:56:53 +02:00
parent 26ef9b45d4
commit dcf0b4274c
15 changed files with 337 additions and 431 deletions

View File

@ -1,10 +1,12 @@
"""Test get secret."""
import allure
import pytest
from .types import ClientRegistry, CommandRunner
@allure.title("Test get_secret command")
@pytest.mark.asyncio
async def test_get_secret(
ssh_command_runner: CommandRunner, client_registry: ClientRegistry
@ -19,7 +21,7 @@ async def test_get_secret(
assert isinstance(result.stdout, str)
assert result.stdout.rstrip() == "mocked-secret-mysecret"
@allure.title("Test with invalid secret name")
@pytest.mark.asyncio
async def test_invalid_secret_name(
ssh_command_runner: CommandRunner, client_registry: ClientRegistry
@ -30,4 +32,25 @@ async def test_invalid_secret_name(
result = await ssh_command_runner("test-client", "get_secret mysecret")
assert result.exit_status == 1
assert result.stderr == "Error: No secret available with the given name."
stderr = result.stderr
assert isinstance(stderr, str)
assert stderr.rstrip() == "Error: No secret available with the given name."
@allure.title("Test get_secret command help")
@pytest.mark.asyncio
async def test_get_secret_cmd_help(ssh_command_runner: CommandRunner, client_registry: ClientRegistry) -> None:
"""Test running get_secret --help"""
await client_registry["add_client"]("test-client", ["mysecret"])
result = await ssh_command_runner("test-client", "get_secret --help")
assert result.exit_status == 0
print(result.stdout)
assert isinstance(result.stdout, str)
lines = result.stdout.splitlines()
assert lines[0] == "get_secret SECRET"
assert len(lines) > 4