diff --git a/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs b/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs index 9cc6e5e994..89deb39140 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(); @@ -77,12 +75,41 @@ public class MediaInfoResolverTests var video = new Movie { - Path = path + Path = "https://url.com/My.Video.mkv" }; - var files = _subtitleResolver.GetExternalFiles(video, Mock.Of(), false); + Assert.Empty(_subtitleResolver.GetExternalFiles(video, Mock.Of(), false)); + } - Assert.Empty(files); + [Theory] + [InlineData(false)] + [InlineData(true)] + public void GetExternalFiles_MissingDirectory_DirectoryNotQueried(bool metadataDirectory) + { + BaseItem.MediaSourceManager = Mock.Of(); + + var video = new Movie + { + Path = VideoDirectoryPath + "/My.Video.mkv" + }; + + string pathNotFoundRegex = metadataDirectory ? MetadataDirectoryRegex : VideoDirectoryRegex; + + var directoryService = new Mock(MockBehavior.Strict); + // any path other than test target exists and provides an empty listing + directoryService.Setup(ds => ds.PathExists(It.IsAny())) + .Returns(true); + directoryService.Setup(ds => ds.GetFilePaths(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns(Array.Empty()); + + directoryService.Setup(ds => ds.PathExists(It.IsRegex(pathNotFoundRegex))) + .Returns(false); + + _subtitleResolver.GetExternalFiles(video, directoryService.Object, false); + + directoryService.Verify( + ds => ds.GetFilePaths(It.IsRegex(pathNotFoundRegex), It.IsAny(), It.IsAny()), + 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 e69de29bb2..0000000000