using ClaudeDo.Worker.Lifecycle;
using Xunit;

namespace ClaudeDo.Worker.Tests.Lifecycle;

public sealed class ClaudeCliPreflightTests
{
    [Fact]
    public async Task NonExistentBinary_ReturnsNotOk_WithError()
    {
        var result = await ClaudeCliPreflight.CheckAsync("definitely-not-a-real-bin-xyz123");

        Assert.False(result.Ok);
        Assert.NotEqual(0, result.ExitCode);
        Assert.NotEmpty(result.Error);
    }

    [Fact]
    public async Task BinaryAcceptingVersionFlag_ReturnsOk_WithVersionOutput()
    {
        // `dotnet --version` is always available in this build environment, exits 0,
        // and prints the SDK version on stdout — same shape as `claude --version`.
        var result = await ClaudeCliPreflight.CheckAsync("dotnet");

        Assert.True(result.Ok, $"expected ok, got exit={result.ExitCode} err='{result.Error}'");
        Assert.Equal(0, result.ExitCode);
        Assert.NotEmpty(result.Version);
    }
}
