"""Test history command."""

from typer.testing import CliRunner

from apiposture_pro.cli.app import app

runner = CliRunner()


def test_history_list_without_license() -> None:
    """Test history list fails without valid license."""
    result = runner.invoke(app, ["history", "list"])

    assert result.exit_code == 1
    assert "No valid license found" in result.stdout


def test_history_show_without_license() -> None:
    """Test history show fails without valid license."""
    result = runner.invoke(app, ["history", "show", "1"])

    assert result.exit_code == 1
    assert "No valid license found" in result.stdout


def test_history_trend_without_license() -> None:
    """Test history trend fails without valid license."""
    result = runner.invoke(app, ["history", "trend"])

    assert result.exit_code == 1
    assert "No valid license found" in result.stdout


def test_history_cleanup_without_license() -> None:
    """Test history cleanup fails without valid license."""
    result = runner.invoke(app, ["history", "cleanup", "--force"])

    assert result.exit_code == 1
    assert "No valid license found" in result.stdout
