mirror of
https://github.com/davidkaya/aryx.git
synced 2026-07-29 07:58:47 +02:00
Run the Copilot CLI version probe through the resolved launch path and args instead of invoking the Windows shim directly. This keeps the version check aligned with the SDK launch strategy and avoids false 'Version unknown' results from the Winget-installed Copilot executable. Add a regression test covering the constructed launch command. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
76 lines
2.5 KiB
C#
76 lines
2.5 KiB
C#
using Kopaya.AgentHost.Contracts;
|
|
using Kopaya.AgentHost.Services;
|
|
|
|
namespace Kopaya.AgentHost.Tests;
|
|
|
|
public sealed class CopilotConnectionMetadataResolverTests
|
|
{
|
|
[Fact]
|
|
public void ParseCliVersionOutput_ReturnsLatestStatusForCurrentInstall()
|
|
{
|
|
SidecarCopilotCliVersionDiagnosticsDto diagnostics =
|
|
CopilotConnectionMetadataResolver.ParseCliVersionOutput(
|
|
"""
|
|
GitHub Copilot CLI 1.0.10
|
|
You are running the latest version.
|
|
""");
|
|
|
|
Assert.Equal("latest", diagnostics.Status);
|
|
Assert.Equal("1.0.10", diagnostics.InstalledVersion);
|
|
Assert.Equal("1.0.10", diagnostics.LatestVersion);
|
|
}
|
|
|
|
[Fact]
|
|
public void ParseCliVersionOutput_ReturnsOutdatedStatusWhenNewerVersionIsAvailable()
|
|
{
|
|
SidecarCopilotCliVersionDiagnosticsDto diagnostics =
|
|
CopilotConnectionMetadataResolver.ParseCliVersionOutput(
|
|
"""
|
|
GitHub Copilot CLI 1.0.9
|
|
A newer version 1.0.10 is available.
|
|
Run 'copilot update' to install it.
|
|
""");
|
|
|
|
Assert.Equal("outdated", diagnostics.Status);
|
|
Assert.Equal("1.0.9", diagnostics.InstalledVersion);
|
|
Assert.Equal("1.0.10", diagnostics.LatestVersion);
|
|
}
|
|
|
|
[Fact]
|
|
public void CreateCliCommand_UsesLaunchPathAndAppendsCommandArguments()
|
|
{
|
|
CopilotCliContext cliContext = new(
|
|
CliPath: @"C:\tools\copilot.exe",
|
|
LaunchPath: @"C:\Windows\System32\cmd.exe",
|
|
LaunchArgs: ["/d", "/s", "/c", "copilot"],
|
|
Environment: new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase));
|
|
|
|
(string executablePath, string[] arguments) =
|
|
CopilotConnectionMetadataResolver.CreateCliCommand(cliContext, "version");
|
|
|
|
Assert.Equal(@"C:\Windows\System32\cmd.exe", executablePath);
|
|
Assert.Equal(["/d", "/s", "/c", "copilot", "version"], arguments);
|
|
}
|
|
|
|
[Fact]
|
|
public void NormalizeHost_StripsSchemeAndTrailingSlash()
|
|
{
|
|
string? host = CopilotConnectionMetadataResolver.NormalizeHost("https://github.example.com/");
|
|
|
|
Assert.Equal("github.example.com", host);
|
|
}
|
|
|
|
[Fact]
|
|
public void ParseOrganizationsOutput_ReturnsDistinctOrganizations()
|
|
{
|
|
IReadOnlyList<string> organizations = CopilotConnectionMetadataResolver.ParseOrganizationsOutput(
|
|
"""
|
|
github
|
|
octo-org
|
|
github
|
|
""");
|
|
|
|
Assert.Equal(["github", "octo-org"], organizations);
|
|
}
|
|
}
|