From d5848bebc6b515216432ed9ad55cfef5ecd01ffb Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Sun, 12 Feb 2023 18:26:40 +0200 Subject: [PATCH] Fix concurrency issue in tests --- .../Infra/ExportWrapper.cs | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/DiscordChatExporter.Cli.Tests/Infra/ExportWrapper.cs b/DiscordChatExporter.Cli.Tests/Infra/ExportWrapper.cs index d43d455..4168ac2 100644 --- a/DiscordChatExporter.Cli.Tests/Infra/ExportWrapper.cs +++ b/DiscordChatExporter.Cli.Tests/Infra/ExportWrapper.cs @@ -44,22 +44,13 @@ public static class ExportWrapper // Perform export only if it hasn't been done before if (!File.Exists(filePath)) { - try + await new ExportChannelsCommand { - await new ExportChannelsCommand - { - Token = Secrets.DiscordToken, - ChannelIds = new[] { channelId }, - ExportFormat = format, - OutputPath = filePath - }.ExecuteAsync(new FakeConsole()); - } - catch - { - // If the export fails, delete the file to prevent it from being used by tests - File.Delete(filePath); - throw; - } + Token = Secrets.DiscordToken, + ChannelIds = new[] { channelId }, + ExportFormat = format, + OutputPath = filePath + }.ExecuteAsync(new FakeConsole()); } return await File.ReadAllTextAsync(filePath);