Files
WorkspaceAccessHost/tests/WorkspaceAccessServer.Tests/ServerCommandLineTests.cs
T
Nitload 0ea679932e
Verify / verify (ubuntu-latest, linux-bionic-arm64) (push) Canceled after 0s
Verify / verify (ubuntu-latest, linux-x64) (push) Canceled after 0s
Verify / verify (windows-latest, win-x64) (push) Canceled after 0s
Verify / postgres (push) Canceled after 0s
Build Charac server and client with OIDC, SSH sessions, and packages
2026-10-05 14:02:50 +08:00

36 lines
1.2 KiB
C#

using Charac.Server.Hosting;
namespace Charac.Server.Tests;
public sealed class ServerCommandLineTests
{
[Fact]
public void ConfigOptionCanPrecedeOrFollowCommand()
{
var first = ServerCommandLine.Parse(["--config", "custom.config", "database", "migrate"]);
var last = ServerCommandLine.Parse(["database", "migrate", "--config=custom.config"]);
Assert.Equal("custom.config", first.ConfigPath);
Assert.Equal(["database", "migrate"], first.Command);
Assert.Equal(first.ConfigPath, last.ConfigPath);
Assert.Equal(first.Command, last.Command);
}
[Theory]
[InlineData("--config")]
[InlineData("--config=")]
[InlineData("--config", "--help")]
[InlineData("--config=a.config", "--config=b.config")]
public void MissingOrRepeatedConfigPathIsRejected(params string[] args)
{
Assert.Throws<ArgumentException>(() => ServerCommandLine.Parse(args));
}
[Fact]
public void ExplicitConfigDoesNotFallBackWhenMissing()
{
var missing = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".config");
Assert.Throws<FileNotFoundException>(() => WorkspaceAccessConfiguration.PathToLoad(missing));
}
}