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"
};
String fileRelativePath;
if (OSHelper.IsLinux)
{
fileRelativePath = "inside/lots/of/subdirectories/file.txt";
}
else
{
fileRelativePath = @"inside\lots\of\subdirectories\file.txt";
}
var fileRelativePath = Path.Combine("inside", "lots", "of", "subdirectories", "file.txt");
IList<DebridClientFile> files =
[
@ -212,7 +203,7 @@ public class DownloadHelperTest
var path = DownloadHelper.GetDownloadPath("/data/downloads", torrent, download, fileSystem);
// 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);
}
@ -226,16 +217,7 @@ public class DownloadHelperTest
FileName = "file.txt"
};
String fileRelativePath;
if (OSHelper.IsLinux)
{
fileRelativePath = "inside/lots/of/subdirectories/file.txt";
}
else
{
fileRelativePath = @"inside\lots\of\subdirectories\file.txt";
}
var fileRelativePath = Path.Combine("inside", "lots", "of", "subdirectories", "file.txt");
IList<DebridClientFile> files =
[
@ -255,7 +237,7 @@ public class DownloadHelperTest
var path = DownloadHelper.GetDownloadPath(torrent, download);
// Assert
var expectedPath = Path.Combine(torrent.RdName, fileRelativePath);
var expectedPath = Path.Combine(torrent.RdName, "inside", "lots", "of", "subdirectories", "file.txt");
Assert.Equal(expectedPath, path);
}
@ -269,16 +251,7 @@ public class DownloadHelperTest
FileName = "file.txt"
};
String fileRelativePath;
if (OSHelper.IsLinux)
{
fileRelativePath = "Torrent Name/Saison 1/file.txt";
}
else
{
fileRelativePath = @"Torrent Name\Saison 1\file.txt";
}
var fileRelativePath = Path.Combine("Torrent Name", "Saison 1", "file.txt");
IList<DebridClientFile> files =
[
@ -315,16 +288,7 @@ public class DownloadHelperTest
FileName = "file.txt"
};
String fileRelativePath;
if (OSHelper.IsLinux)
{
fileRelativePath = "Torrent Name/Saison 1/file.txt";
}
else
{
fileRelativePath = @"Torrent Name\Saison 1\file.txt";
}
var fileRelativePath = Path.Combine("Torrent Name", "Saison 1", "file.txt");
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 filePath;
if (OSHelper.IsLinux)
{
downloadPath = $"{settings.DownloadClient.DownloadPath}/{torrent.Category}";
torrentPath = $"{downloadPath}/{torrent.RdName}";
filePath = $"{torrentPath}/{downloads[0].FileName}";
}
else
{
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 category = torrent.Category!;
var torrentName = torrent.RdName!;
var fileName = downloads[0].FileName!;
downloadPath = Path.Combine(settings.DownloadClient.DownloadPath, category);
torrentPath = Path.Combine(downloadPath, torrentName);
filePath = Path.Combine(torrentPath, fileName);
var fileSystemMock = new MockFileSystem(new Dictionary<String, MockFileData>
{