Merge pull request #959 from omgbeez/upstream/fix-tests-macos

fix(tests): Fix tests to work on macos (and linux, and windows)
This commit is contained in:
Roger Far 2026-04-21 07:23:15 -06:00 committed by GitHub
commit 145ea9a8ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 63 deletions

View file

@ -181,16 +181,7 @@ public class DownloadHelperTest
FileName = "file.txt" FileName = "file.txt"
}; };
String fileRelativePath; var fileRelativePath = Path.Combine("inside", "lots", "of", "subdirectories", "file.txt");
if (OSHelper.IsLinux)
{
fileRelativePath = "inside/lots/of/subdirectories/file.txt";
}
else
{
fileRelativePath = @"inside\lots\of\subdirectories\file.txt";
}
IList<DebridClientFile> files = IList<DebridClientFile> files =
[ [
@ -212,7 +203,7 @@ public class DownloadHelperTest
var path = DownloadHelper.GetDownloadPath("/data/downloads", torrent, download, fileSystem); var path = DownloadHelper.GetDownloadPath("/data/downloads", torrent, download, fileSystem);
// Assert // Assert
var expectedPath = Path.Combine("/data/downloads", torrent.RdName, fileRelativePath); var expectedPath = Path.Combine("/data/downloads", torrent.RdName, "inside", "lots", "of", "subdirectories", "file.txt");
Assert.Equal(expectedPath, path); Assert.Equal(expectedPath, path);
} }
@ -226,16 +217,7 @@ public class DownloadHelperTest
FileName = "file.txt" FileName = "file.txt"
}; };
String fileRelativePath; var fileRelativePath = Path.Combine("inside", "lots", "of", "subdirectories", "file.txt");
if (OSHelper.IsLinux)
{
fileRelativePath = "inside/lots/of/subdirectories/file.txt";
}
else
{
fileRelativePath = @"inside\lots\of\subdirectories\file.txt";
}
IList<DebridClientFile> files = IList<DebridClientFile> files =
[ [
@ -255,7 +237,7 @@ public class DownloadHelperTest
var path = DownloadHelper.GetDownloadPath(torrent, download); var path = DownloadHelper.GetDownloadPath(torrent, download);
// Assert // Assert
var expectedPath = Path.Combine(torrent.RdName, fileRelativePath); var expectedPath = Path.Combine(torrent.RdName, "inside", "lots", "of", "subdirectories", "file.txt");
Assert.Equal(expectedPath, path); Assert.Equal(expectedPath, path);
} }
@ -269,16 +251,7 @@ public class DownloadHelperTest
FileName = "file.txt" FileName = "file.txt"
}; };
String fileRelativePath; var fileRelativePath = Path.Combine("Torrent Name", "Saison 1", "file.txt");
if (OSHelper.IsLinux)
{
fileRelativePath = "Torrent Name/Saison 1/file.txt";
}
else
{
fileRelativePath = @"Torrent Name\Saison 1\file.txt";
}
IList<DebridClientFile> files = IList<DebridClientFile> files =
[ [
@ -315,16 +288,7 @@ public class DownloadHelperTest
FileName = "file.txt" FileName = "file.txt"
}; };
String fileRelativePath; var fileRelativePath = Path.Combine("Torrent Name", "Saison 1", "file.txt");
if (OSHelper.IsLinux)
{
fileRelativePath = "Torrent Name/Saison 1/file.txt";
}
else
{
fileRelativePath = @"Torrent Name\Saison 1\file.txt";
}
IList<DebridClientFile> files = IList<DebridClientFile> files =
[ [

View file

@ -1,8 +0,0 @@
using System.Runtime.InteropServices;
namespace RdtClient.Service.Test.Helpers;
public static class OSHelper
{
public static Boolean IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
}

View file

@ -94,19 +94,13 @@ public class TorrentsTest
String torrentPath; String torrentPath;
String filePath; String filePath;
if (OSHelper.IsLinux) var category = torrent.Category!;
{ var torrentName = torrent.RdName!;
downloadPath = $"{settings.DownloadClient.DownloadPath}/{torrent.Category}"; var fileName = downloads[0].FileName!;
torrentPath = $"{downloadPath}/{torrent.RdName}";
filePath = $"{torrentPath}/{downloads[0].FileName}"; downloadPath = Path.Combine(settings.DownloadClient.DownloadPath, category);
} torrentPath = Path.Combine(downloadPath, torrentName);
else filePath = Path.Combine(torrentPath, fileName);
{
Settings.Get.DownloadClient.DownloadPath = settings.DownloadClient.DownloadPath = @"C:\Downloads";
downloadPath = @$"{settings.DownloadClient.DownloadPath}\{torrent.Category}";
torrentPath = @$"{downloadPath}\{torrent.RdName}";
filePath = @$"{torrentPath}\{downloads[0].FileName}";
}
var fileSystemMock = new MockFileSystem(new Dictionary<String, MockFileData> var fileSystemMock = new MockFileSystem(new Dictionary<String, MockFileData>
{ {