"""Tests for agentic_devtools.cli.state.show_cmd."""

import sys
from io import StringIO
from unittest.mock import patch

from agentic_devtools import state
from agentic_devtools.cli import state as cli_state


def test_show_empty_state(temp_state_dir, clear_state_before):
    """Test showing empty state."""
    with patch.object(sys, "argv", ["agdt-show"]):
        with patch("sys.stdout", new_callable=StringIO) as mock_stdout:
            cli_state.show_cmd()
            assert "(empty state)" in mock_stdout.getvalue()


def test_show_state_with_values(temp_state_dir, clear_state_before):
    """Test showing state with values."""
    state.set_value("test", "value")
    with patch.object(sys, "argv", ["agdt-show"]):
        with patch("sys.stdout", new_callable=StringIO) as mock_stdout:
            cli_state.show_cmd()
            output = mock_stdout.getvalue()
            assert "test" in output
            assert "value" in output
