From 8664993ff6c24a5261b1a7667726823904e1ae07 Mon Sep 17 00:00:00 2001 From: omgbeez <251408589+omgbeez@users.noreply.github.com> Date: Mon, 20 Apr 2026 19:44:07 -0400 Subject: [PATCH] fix(tests): Fix tests to work on macos (and linux, and windows) Windows is the odd OS out here, adjusting logic for test data. --- .../Helpers/DownloadHelperTest.cs | 24 +++++++++---------- .../Helpers/OSHelper.cs | 2 +- .../Services/TorrentsTest.cs | 14 +++++------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/server/RdtClient.Service.Test/Helpers/DownloadHelperTest.cs b/server/RdtClient.Service.Test/Helpers/DownloadHelperTest.cs index 90ba064..71ddf38 100644 --- a/server/RdtClient.Service.Test/Helpers/DownloadHelperTest.cs +++ b/server/RdtClient.Service.Test/Helpers/DownloadHelperTest.cs @@ -183,13 +183,13 @@ public class DownloadHelperTest String fileRelativePath; - if (OSHelper.IsLinux) + if (OSHelper.IsWindows) { - fileRelativePath = "inside/lots/of/subdirectories/file.txt"; + fileRelativePath = @"inside\lots\of\subdirectories\file.txt"; } else { - fileRelativePath = @"inside\lots\of\subdirectories\file.txt"; + fileRelativePath = "inside/lots/of/subdirectories/file.txt"; } IList files = @@ -228,13 +228,13 @@ public class DownloadHelperTest String fileRelativePath; - if (OSHelper.IsLinux) + if (OSHelper.IsWindows) { - fileRelativePath = "inside/lots/of/subdirectories/file.txt"; + fileRelativePath = @"inside\lots\of\subdirectories\file.txt"; } else { - fileRelativePath = @"inside\lots\of\subdirectories\file.txt"; + fileRelativePath = "inside/lots/of/subdirectories/file.txt"; } IList files = @@ -271,13 +271,13 @@ public class DownloadHelperTest String fileRelativePath; - if (OSHelper.IsLinux) + if (OSHelper.IsWindows) { - fileRelativePath = "Torrent Name/Saison 1/file.txt"; + fileRelativePath = @"Torrent Name\Saison 1\file.txt"; } else { - fileRelativePath = @"Torrent Name\Saison 1\file.txt"; + fileRelativePath = "Torrent Name/Saison 1/file.txt"; } IList files = @@ -317,13 +317,13 @@ public class DownloadHelperTest String fileRelativePath; - if (OSHelper.IsLinux) + if (OSHelper.IsWindows) { - fileRelativePath = "Torrent Name/Saison 1/file.txt"; + fileRelativePath = @"Torrent Name\Saison 1\file.txt"; } else { - fileRelativePath = @"Torrent Name\Saison 1\file.txt"; + fileRelativePath = "Torrent Name/Saison 1/file.txt"; } IList files = diff --git a/server/RdtClient.Service.Test/Helpers/OSHelper.cs b/server/RdtClient.Service.Test/Helpers/OSHelper.cs index 2a99f74..57fb3ad 100644 --- a/server/RdtClient.Service.Test/Helpers/OSHelper.cs +++ b/server/RdtClient.Service.Test/Helpers/OSHelper.cs @@ -4,5 +4,5 @@ namespace RdtClient.Service.Test.Helpers; public static class OSHelper { - public static Boolean IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); + public static Boolean IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); } diff --git a/server/RdtClient.Service.Test/Services/TorrentsTest.cs b/server/RdtClient.Service.Test/Services/TorrentsTest.cs index 7018d59..bb25003 100644 --- a/server/RdtClient.Service.Test/Services/TorrentsTest.cs +++ b/server/RdtClient.Service.Test/Services/TorrentsTest.cs @@ -94,19 +94,19 @@ public class TorrentsTest String torrentPath; String filePath; - if (OSHelper.IsLinux) - { - downloadPath = $"{settings.DownloadClient.DownloadPath}/{torrent.Category}"; - torrentPath = $"{downloadPath}/{torrent.RdName}"; - filePath = $"{torrentPath}/{downloads[0].FileName}"; - } - else + if (OSHelper.IsWindows) { Settings.Get.DownloadClient.DownloadPath = settings.DownloadClient.DownloadPath = @"C:\Downloads"; downloadPath = @$"{settings.DownloadClient.DownloadPath}\{torrent.Category}"; torrentPath = @$"{downloadPath}\{torrent.RdName}"; filePath = @$"{torrentPath}\{downloads[0].FileName}"; } + else + { + downloadPath = $"{settings.DownloadClient.DownloadPath}/{torrent.Category}"; + torrentPath = $"{downloadPath}/{torrent.RdName}"; + filePath = $"{torrentPath}/{downloads[0].FileName}"; + } var fileSystemMock = new MockFileSystem(new Dictionary {