fix(CLI-47,CLI-48,CLI-49,CLI-50): align alarm feed clients
This commit is contained in:
@@ -705,6 +705,50 @@ public sealed class MxGatewayClientCliTests
|
||||
Assert.Equal(string.Empty, error.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Verifies that false alarm-feed status flags remain explicit in text while protobuf JSON omits defaults.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task RunAsync_StreamAlarms_StatusFramesDistinguishTextFromProtobufJson()
|
||||
{
|
||||
FakeCliClient fakeClient = new();
|
||||
fakeClient.AlarmFeedMessages.Add(new AlarmFeedMessage
|
||||
{
|
||||
ProviderStatus = new AlarmProviderStatus { Degraded = false },
|
||||
});
|
||||
fakeClient.AlarmFeedMessages.Add(new AlarmFeedMessage
|
||||
{
|
||||
SnapshotStatus = new AlarmSnapshotStatus { Truncated = false },
|
||||
});
|
||||
|
||||
using var textOutput = new StringWriter();
|
||||
using var textError = new StringWriter();
|
||||
int textExit = await MxGatewayClientCli.RunAsync(
|
||||
["stream-alarms", "--endpoint", "http://localhost:5000", "--api-key", "test-api-key", "--max-events", "2"],
|
||||
textOutput,
|
||||
textError,
|
||||
_ => fakeClient);
|
||||
|
||||
Assert.Equal(0, textExit);
|
||||
Assert.Equal(
|
||||
["provider-status mode=Unspecified degraded=false reason=\"\"", "snapshot-status truncated=false"],
|
||||
textOutput.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries));
|
||||
Assert.Equal(string.Empty, textError.ToString());
|
||||
|
||||
using var jsonOutput = new StringWriter();
|
||||
using var jsonError = new StringWriter();
|
||||
int jsonExit = await MxGatewayClientCli.RunAsync(
|
||||
["stream-alarms", "--endpoint", "http://localhost:5000", "--api-key", "test-api-key", "--max-events", "2", "--jsonl"],
|
||||
jsonOutput,
|
||||
jsonError,
|
||||
_ => fakeClient);
|
||||
|
||||
Assert.Equal(0, jsonExit);
|
||||
Assert.Equal(
|
||||
["{ \"providerStatus\": { } }", "{ \"snapshotStatus\": { } }"],
|
||||
jsonOutput.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries));
|
||||
Assert.Equal(string.Empty, jsonError.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Verifies that acknowledge-alarm builds a request and prints the JSON reply.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user