diff options
| -rw-r--r-- | tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs | 42 | ||||
| -rw-r--r-- | tests/Jellyfin.Providers.Tests/Test Data/Video/My.Video.mkv | 0 |
2 files changed, 34 insertions, 8 deletions
diff --git a/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs b/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs index 9cc6e5e99..89deb3914 100644 --- a/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs +++ b/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs @@ -64,10 +64,8 @@ public class MediaInfoResolverTests _subtitleResolver = new SubtitleResolver(_localizationManager, mediaEncoder.Object, new NamingOptions()); } - [Theory] - [InlineData("https://url.com/My.Video.mkv")] - [InlineData("non-existent/path")] - public void GetExternalFiles_BadPaths_ReturnsNoSubtitles(string path) + [Fact] + public void GetExternalFiles_BadProtocol_ReturnsNoSubtitles() { // need a media source manager capable of returning something other than file protocol var mediaSourceManager = new Mock<IMediaSourceManager>(); @@ -77,12 +75,41 @@ public class MediaInfoResolverTests var video = new Movie { - Path = path + Path = "https://url.com/My.Video.mkv" + }; + + Assert.Empty(_subtitleResolver.GetExternalFiles(video, Mock.Of<IDirectoryService>(), false)); + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public void GetExternalFiles_MissingDirectory_DirectoryNotQueried(bool metadataDirectory) + { + BaseItem.MediaSourceManager = Mock.Of<IMediaSourceManager>(); + + var video = new Movie + { + Path = VideoDirectoryPath + "/My.Video.mkv" }; - var files = _subtitleResolver.GetExternalFiles(video, Mock.Of<IDirectoryService>(), false); + string pathNotFoundRegex = metadataDirectory ? MetadataDirectoryRegex : VideoDirectoryRegex; + + var directoryService = new Mock<IDirectoryService>(MockBehavior.Strict); + // any path other than test target exists and provides an empty listing + directoryService.Setup(ds => ds.PathExists(It.IsAny<string>())) + .Returns(true); + directoryService.Setup(ds => ds.GetFilePaths(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>())) + .Returns(Array.Empty<string>()); + + directoryService.Setup(ds => ds.PathExists(It.IsRegex(pathNotFoundRegex))) + .Returns(false); + + _subtitleResolver.GetExternalFiles(video, directoryService.Object, false); - Assert.Empty(files); + directoryService.Verify( + ds => ds.GetFilePaths(It.IsRegex(pathNotFoundRegex), It.IsAny<bool>(), It.IsAny<bool>()), + Times.Never); } [Theory] @@ -132,7 +159,6 @@ public class MediaInfoResolverTests [Theory] [InlineData("https://url.com/My.Video.mkv")] - [InlineData("non-existent/path")] [InlineData(VideoDirectoryPath)] // valid but no files found for this test public async void GetExternalStreams_BadPaths_ReturnsNoSubtitles(string path) { diff --git a/tests/Jellyfin.Providers.Tests/Test Data/Video/My.Video.mkv b/tests/Jellyfin.Providers.Tests/Test Data/Video/My.Video.mkv deleted file mode 100644 index e69de29bb..000000000 --- a/tests/Jellyfin.Providers.Tests/Test Data/Video/My.Video.mkv +++ /dev/null |
