fix(cli): deploy area names a malformed summary as an invalid area deployment summary (Gitea #40 review)
This commit is contained in:
@@ -115,7 +115,8 @@ public static class DeployCommands
|
||||
result, urlOption, formatOption, usernameOption, passwordOption,
|
||||
new MgmtDeployAreaCommand(areaId, force),
|
||||
timeout: BulkDeployTimeout,
|
||||
onSuccess: json => HandleSiteDeploymentResponse(json, CommandHelpers.ResolveFormat(result, formatOption, CliConfig.Load())));
|
||||
onSuccess: json => HandleSiteDeploymentResponse(
|
||||
json, CommandHelpers.ResolveFormat(result, formatOption, CliConfig.Load()), "area deployment"));
|
||||
});
|
||||
return cmd;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace ZB.MOM.WW.ScadaBridge.CLI.Tests;
|
||||
/// exactly like <c>deploy site</c>: a per-instance failure is a successful HTTP
|
||||
/// call, so without that a script could not detect it.
|
||||
/// </summary>
|
||||
[Collection("Console")]
|
||||
public class DeployAreaExitCodeTests
|
||||
{
|
||||
/// <summary>Verifies the wire payload and the exit code derived from the summary.</summary>
|
||||
@@ -65,8 +66,23 @@ public class DeployAreaExitCodeTests
|
||||
string[] args = ["deploy", "area", "--id", "12", "--url", $"http://127.0.0.1:{port}",
|
||||
"--username", "test", "--password", "test", "--format", "json"];
|
||||
if (force) args = [.. args, "--force"];
|
||||
var exit = await root.Parse(args).InvokeAsync();
|
||||
await server.WaitAsync(TimeSpan.FromSeconds(5));
|
||||
var stderr = new StringWriter();
|
||||
var originalError = Console.Error;
|
||||
Console.SetError(stderr);
|
||||
int exit;
|
||||
try
|
||||
{
|
||||
exit = await root.Parse(args).InvokeAsync();
|
||||
await server.WaitAsync(TimeSpan.FromSeconds(5));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Console.SetError(originalError);
|
||||
}
|
||||
|
||||
// A malformed summary is named for what was asked: an AREA deployment.
|
||||
if (response.Contains("unexpected"))
|
||||
Assert.Contains("invalid area deployment summary", stderr.ToString());
|
||||
|
||||
Assert.Equal(expected, exit);
|
||||
using var payload = JsonDocument.Parse(requestBody!);
|
||||
|
||||
Reference in New Issue
Block a user