Worker now runs `claude --version` before listening; on non-zero exit it logs critical and exits with code 1. Skippable via env var CLAUDEDO_SKIP_CLI_PREFLIGHT=1 for environments without the CLI (tests, dev). Closes verification step 2 / open.md item 3.1. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
30 lines
963 B
C#
30 lines
963 B
C#
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);
|
|
}
|
|
}
|