48 lines
1.9 KiB
C#
48 lines
1.9 KiB
C#
using ClaudeDo.Worker.Planning;
|
|
|
|
namespace ClaudeDo.Worker.Tests.Planning;
|
|
|
|
public sealed class WindowsTerminalPlanningLauncherTests
|
|
{
|
|
private static PlanningSessionStartContext MakeStartCtx(string? wd = null)
|
|
{
|
|
var workingDir = wd ?? Path.GetTempPath();
|
|
var dir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
|
Directory.CreateDirectory(dir);
|
|
return new PlanningSessionStartContext(
|
|
ParentTaskId: "task-1",
|
|
WorkingDir: workingDir,
|
|
Files: new PlanningSessionFiles(
|
|
SessionDirectory: dir,
|
|
McpConfigPath: Path.Combine(dir, "mcp.json"),
|
|
SystemPromptPath: Path.Combine(dir, "system-prompt.md"),
|
|
InitialPromptPath: Path.Combine(dir, "initial-prompt.txt")));
|
|
}
|
|
|
|
[Fact]
|
|
public async Task LaunchStartAsync_WorkingDirMissing_Throws()
|
|
{
|
|
var ctx = MakeStartCtx(wd: Path.Combine(Path.GetTempPath(), "nonexistent_" + Guid.NewGuid()));
|
|
var sut = new WindowsTerminalPlanningLauncher(wtPath: "wt", claudePath: "claude");
|
|
var ex = await Assert.ThrowsAsync<PlanningLaunchException>(() =>
|
|
sut.LaunchStartAsync(ctx, CancellationToken.None));
|
|
Assert.Contains("Working directory", ex.Message);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task LaunchStartAsync_WtMissing_Throws()
|
|
{
|
|
var ctx = MakeStartCtx();
|
|
File.WriteAllText(ctx.Files.McpConfigPath, "{}");
|
|
File.WriteAllText(ctx.Files.SystemPromptPath, "sp");
|
|
File.WriteAllText(ctx.Files.InitialPromptPath, "ip");
|
|
|
|
var sut = new WindowsTerminalPlanningLauncher(
|
|
wtPath: "C:/no/such/wt.exe",
|
|
claudePath: "claude");
|
|
var ex = await Assert.ThrowsAsync<PlanningLaunchException>(() =>
|
|
sut.LaunchStartAsync(ctx, CancellationToken.None));
|
|
Assert.Contains("Windows Terminal", ex.Message);
|
|
}
|
|
}
|