Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,8 @@ public async Task TryGetFailure_Should_Report_A_Nonzero_Exit_With_The_Stderr_Tai
await Assert.That(failure).IsNotNull();
await Assert.That(failure!.Message).Contains("exited with code 2");
await Assert.That(failure.Message).Contains("Usage: contender-probe");
await Assert.That(failure.Message).StartsWith(
"The background service contender (pid " + contender.ProcessId.ToString(CultureInfo.InvariantCulture) + ") exited with code 2.\n");
}
finally
{
Expand Down
35 changes: 35 additions & 0 deletions tests/OpenCode.Sdk.Tests/Hosting/OpenCodeServerContractTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,41 @@ public async Task StartAsync_Should_Refuse_A_Blank_Command_Entry()
new OpenCodeServerOptions { Command = ["bun", " "] })).Throws<ArgumentException>();
}

[Test]
[Arguments(false, "OpenCodeServerOptions.Command needs the executable and its leading arguments.")]
[Arguments(true, "OpenCodeServerOptions.Command entries cannot be blank.")]
public Task StartAsync_Should_Name_The_Refused_Command_And_Its_Options(bool blankEntry, string text) =>
AssertOptionsRefusalAsync(
async () => await OpenCodeServer.StartAsync(new OpenCodeServerOptions { Command = RefusedCommand(blankEntry) }),
text);

[Test]
[Arguments(false, "OpenCodeServerEnsureOptions.Command needs the executable and its leading arguments.")]
[Arguments(true, "OpenCodeServerEnsureOptions.Command entries cannot be blank.")]
public Task EnsureAsync_Should_Name_The_Refused_Command_And_Its_Options(bool blankEntry, string text) =>
AssertOptionsRefusalAsync(
async () => await OpenCodeServer.EnsureAsync(new OpenCodeServerEnsureOptions { Command = RefusedCommand(blankEntry) }),
text);

private static string[] RefusedCommand(bool blankEntry) => blankEntry ? ["bun", " "] : [];

/// <summary>
/// The door refuses with exactly <paramref name="text"/> for its public <c>options</c> parameter, in the
/// message <see cref="ArgumentException"/> renders on each runtime.
/// </summary>
private static async Task AssertOptionsRefusalAsync(Func<Task> door, string text)
{
var failure = await Assert.That(door).Throws<ArgumentException>();

await Assert.That(failure!.Message).IsEqualTo(
#if NET
text + " (Parameter 'options')");
#else
text + Environment.NewLine + "Parameter name: options");
#endif
await Assert.That(failure.ParamName).IsEqualTo("options");
}

[Test]
public async Task Endpoint_Should_Throw_The_Mock_Seam_Failure_On_A_Bare_Mock()
{
Expand Down
Loading