"""Tests for concurrent evaluation CLI guards."""

import pytest
from click.testing import CliRunner


class TestDockerGuard:
    def test_docker_blocks_workers(self):
        from clawbench.cli import cli
        runner = CliRunner()
        result = runner.invoke(cli, [
            "eval",
            "--skill", "/dev/null",
            "--tasks-dir", "/dev/null",
            "-e", "docker",
            "--workers", "3",
        ])
        assert result.exit_code != 0
        assert "cloud environment" in result.output

    def test_daytona_allows_workers(self):
        """Daytona should not trigger the cloud guard (may fail later without keys)."""
        from clawbench.cli import cli
        runner = CliRunner()
        result = runner.invoke(cli, [
            "eval",
            "--skill", "/dev/null",
            "--tasks-dir", "/dev/null",
            "-e", "daytona",
            "--workers", "3",
        ])
        # Should not fail on the guard — may fail later on missing skill/tasks
        assert "cloud environment" not in (result.output or "")

    def test_optimize_docker_blocks_workers(self):
        from clawbench.cli import cli
        runner = CliRunner()
        result = runner.invoke(cli, [
            "optimize",
            "--skill", "/dev/null",
            "--tasks-dir", "/tmp",
            "-e", "docker",
            "--workers", "3",
        ])
        assert result.exit_code != 0
        if result.output:
            assert "cloud environment" in result.output
