Don't consider it an error if there is nothing to export (#1349)

This commit is contained in:
Leonardo Mosquera
2025-04-01 18:14:35 -03:00
committed by GitHub
parent cf7580014c
commit 7add81a472
6 changed files with 110 additions and 49 deletions

View File

@@ -146,4 +146,33 @@ public class DateRangeSpecs
.WhenTypeIs<DateTimeOffset>()
);
}
[Fact]
public async Task Export_file_is_created_even_when_nothing_to_export()
{
var long_in_the_past = new DateTimeOffset(1921, 08, 01, 0, 0, 0, TimeSpan.Zero);
// Arrange
var before = long_in_the_past;
using var file = TempFile.Create();
// Act
await new ExportChannelsCommand
{
Token = Secrets.DiscordToken,
ChannelIds = [ChannelIds.DateRangeTestCases],
ExportFormat = ExportFormat.Json,
OutputPath = file.Path,
Before = Snowflake.FromDate(before),
}.ExecuteAsync(new FakeConsole());
// Assert
var timestamps = Json.Parse(await File.ReadAllTextAsync(file.Path))
.GetProperty("messages")
.EnumerateArray()
.Select(j => j.GetProperty("timestamp").GetDateTimeOffset())
.ToArray();
timestamps.Should().BeEmpty();
}
}