mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 09:59:06 -07:00
Add unit test for log file not found
This commit is contained in:
parent
918b627472
commit
d82d025b24
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user