diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Jellyfin.Api.Tests/Controllers/SystemControllerTests.cs | 35 | ||||
| -rw-r--r-- | tests/Jellyfin.Server.Integration.Tests/AuthHelper.cs | 3 |
2 files changed, 37 insertions, 1 deletions
diff --git a/tests/Jellyfin.Api.Tests/Controllers/SystemControllerTests.cs b/tests/Jellyfin.Api.Tests/Controllers/SystemControllerTests.cs new file mode 100644 index 000000000..dd84c1a18 --- /dev/null +++ b/tests/Jellyfin.Api.Tests/Controllers/SystemControllerTests.cs @@ -0,0 +1,35 @@ +using Jellyfin.Api.Controllers; +using MediaBrowser.Common.Net; +using MediaBrowser.Controller; +using MediaBrowser.Model.IO; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Moq; +using Xunit; + +namespace Jellyfin.Api.Tests.Controllers +{ + public class SystemControllerTests + { + [Fact] + public void GetLogFile_FileDoesNotExist_ReturnsNotFound() + { + var mockFileSystem = new Mock<IFileSystem>(); + mockFileSystem + .Setup(fs => fs.GetFiles(It.IsAny<string>(), It.IsAny<bool>())) + .Returns([new() { Name = "file1.txt" }, new() { Name = "file2.txt" }]); + + var controller = new SystemController( + Mock.Of<ILogger<SystemController>>(), + Mock.Of<IServerApplicationHost>(), + Mock.Of<IServerApplicationPaths>(), + mockFileSystem.Object, + Mock.Of<INetworkManager>(), + Mock.Of<ISystemManager>()); + + var result = controller.GetLogFile("DOES_NOT_EXIST.txt"); + + Assert.IsType<NotFoundObjectResult>(result); + } + } +} diff --git a/tests/Jellyfin.Server.Integration.Tests/AuthHelper.cs b/tests/Jellyfin.Server.Integration.Tests/AuthHelper.cs index 4e8aec9f1..2f2149504 100644 --- a/tests/Jellyfin.Server.Integration.Tests/AuthHelper.cs +++ b/tests/Jellyfin.Server.Integration.Tests/AuthHelper.cs @@ -7,6 +7,7 @@ using System.Text.Json; using System.Threading.Tasks; using Jellyfin.Api.Models.StartupDtos; using Jellyfin.Api.Models.UserDtos; +using Jellyfin.Extensions; using Jellyfin.Extensions.Json; using MediaBrowser.Model.Dto; using Xunit; @@ -56,7 +57,7 @@ namespace Jellyfin.Server.Integration.Tests public static async Task<BaseItemDto> GetRootFolderDtoAsync(HttpClient client, Guid userId = default) { - if (userId.Equals(default)) + if (userId.IsEmpty()) { var userDto = await GetUserDtoAsync(client); userId = userDto.Id; |
