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,
|
result, urlOption, formatOption, usernameOption, passwordOption,
|
||||||
new MgmtDeployAreaCommand(areaId, force),
|
new MgmtDeployAreaCommand(areaId, force),
|
||||||
timeout: BulkDeployTimeout,
|
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;
|
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
|
/// exactly like <c>deploy site</c>: a per-instance failure is a successful HTTP
|
||||||
/// call, so without that a script could not detect it.
|
/// call, so without that a script could not detect it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Collection("Console")]
|
||||||
public class DeployAreaExitCodeTests
|
public class DeployAreaExitCodeTests
|
||||||
{
|
{
|
||||||
/// <summary>Verifies the wire payload and the exit code derived from the summary.</summary>
|
/// <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}",
|
string[] args = ["deploy", "area", "--id", "12", "--url", $"http://127.0.0.1:{port}",
|
||||||
"--username", "test", "--password", "test", "--format", "json"];
|
"--username", "test", "--password", "test", "--format", "json"];
|
||||||
if (force) args = [.. args, "--force"];
|
if (force) args = [.. args, "--force"];
|
||||||
var exit = await root.Parse(args).InvokeAsync();
|
var stderr = new StringWriter();
|
||||||
await server.WaitAsync(TimeSpan.FromSeconds(5));
|
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);
|
Assert.Equal(expected, exit);
|
||||||
using var payload = JsonDocument.Parse(requestBody!);
|
using var payload = JsonDocument.Parse(requestBody!);
|
||||||
|
|||||||
Reference in New Issue
Block a user