aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Server.Implementations.Tests/IO/ManagedFileSystemTests.cs
diff options
context:
space:
mode:
authorgnattu <gnattu@users.noreply.github.com>2024-05-13 12:47:35 -0400
committerJoshua M. Boniface <joshua@boniface.me>2024-05-13 12:47:35 -0400
commit5ac518b02ac95ebf67a16388fe4d1a71ca1a5d83 (patch)
treefe1aecd75c147e8eaaf16bca3b23c2beeb7a6b94 /tests/Jellyfin.Server.Implementations.Tests/IO/ManagedFileSystemTests.cs
parent3564b00fc0807f0578e40891061793ef727d2dd5 (diff)
Backport pull request #11570 from jellyfin/release-10.9.z
Fix absolute path checking on windows Original-merge: 6689d837d6dcfa0925efdbd9c76a7e1fe4f7cc54 Merged-by: crobibero <cody@robibe.ro> Backported-by: Joshua M. Boniface <joshua@boniface.me>
Diffstat (limited to 'tests/Jellyfin.Server.Implementations.Tests/IO/ManagedFileSystemTests.cs')
-rw-r--r--tests/Jellyfin.Server.Implementations.Tests/IO/ManagedFileSystemTests.cs33
1 files changed, 22 insertions, 11 deletions
diff --git a/tests/Jellyfin.Server.Implementations.Tests/IO/ManagedFileSystemTests.cs b/tests/Jellyfin.Server.Implementations.Tests/IO/ManagedFileSystemTests.cs
index d991f5574..95a5b8179 100644
--- a/tests/Jellyfin.Server.Implementations.Tests/IO/ManagedFileSystemTests.cs
+++ b/tests/Jellyfin.Server.Implementations.Tests/IO/ManagedFileSystemTests.cs
@@ -20,26 +20,37 @@ namespace Jellyfin.Server.Implementations.Tests.IO
_sut = _fixture.Create<ManagedFileSystem>();
}
- [Theory]
+ [SkippableTheory]
[InlineData("/Volumes/Library/Sample/Music/Playlists/", "../Beethoven/Misc/Moonlight Sonata.mp3", "/Volumes/Library/Sample/Music/Beethoven/Misc/Moonlight Sonata.mp3")]
[InlineData("/Volumes/Library/Sample/Music/Playlists/", "../../Beethoven/Misc/Moonlight Sonata.mp3", "/Volumes/Library/Sample/Beethoven/Misc/Moonlight Sonata.mp3")]
[InlineData("/Volumes/Library/Sample/Music/Playlists/", "Beethoven/Misc/Moonlight Sonata.mp3", "/Volumes/Library/Sample/Music/Playlists/Beethoven/Misc/Moonlight Sonata.mp3")]
- public void MakeAbsolutePathCorrectlyHandlesRelativeFilePaths(
+ [InlineData("/Volumes/Library/Sample/Music/Playlists/", "/mnt/Beethoven/Misc/Moonlight Sonata.mp3", "/mnt/Beethoven/Misc/Moonlight Sonata.mp3")]
+ public void MakeAbsolutePathCorrectlyHandlesRelativeFilePathsOnUnixLike(
string folderPath,
string filePath,
string expectedAbsolutePath)
{
+ Skip.If(OperatingSystem.IsWindows());
+
+ var generatedPath = _sut.MakeAbsolutePath(folderPath, filePath);
+ Assert.Equal(expectedAbsolutePath, generatedPath);
+ }
+
+ [SkippableTheory]
+ [InlineData(@"C:\\Volumes\Library\Sample\Music\Playlists\", @"..\Beethoven\Misc\Moonlight Sonata.mp3", @"C:\Volumes\Library\Sample\Music\Beethoven\Misc\Moonlight Sonata.mp3")]
+ [InlineData(@"C:\\Volumes\Library\Sample\Music\Playlists\", @"..\..\Beethoven\Misc\Moonlight Sonata.mp3", @"C:\Volumes\Library\Sample\Beethoven\Misc\Moonlight Sonata.mp3")]
+ [InlineData(@"C:\\Volumes\Library\Sample\Music\Playlists\", @"Beethoven\Misc\Moonlight Sonata.mp3", @"C:\Volumes\Library\Sample\Music\Playlists\Beethoven\Misc\Moonlight Sonata.mp3")]
+ [InlineData(@"C:\\Volumes\Library\Sample\Music\Playlists\", @"D:\\Beethoven\Misc\Moonlight Sonata.mp3", @"D:\\Beethoven\Misc\Moonlight Sonata.mp3")]
+ public void MakeAbsolutePathCorrectlyHandlesRelativeFilePathsOnWindows(
+ string folderPath,
+ string filePath,
+ string expectedAbsolutePath)
+ {
+ Skip.If(!OperatingSystem.IsWindows());
+
var generatedPath = _sut.MakeAbsolutePath(folderPath, filePath);
- if (OperatingSystem.IsWindows())
- {
- var expectedWindowsPath = expectedAbsolutePath.Replace('/', '\\');
- Assert.Equal(expectedWindowsPath, generatedPath.Split(':')[1]);
- }
- else
- {
- Assert.Equal(expectedAbsolutePath, generatedPath);
- }
+ Assert.Equal(expectedAbsolutePath, generatedPath);
}
[Theory]