mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-08-30 23:00:06 -04:00
Cleanup and moved a test to proper place
This commit is contained in:
parent
165757d338
commit
c57b77f092
@ -3,18 +3,9 @@ using Xunit;
|
||||
|
||||
namespace API.Tests.Services
|
||||
{
|
||||
|
||||
public class ImageProviderTest
|
||||
{
|
||||
// [Theory]
|
||||
// [InlineData("v10.cbz", "v10.expected.jpg")]
|
||||
// [InlineData("v10 - with folder.cbz", "v10 - with folder.expected.jpg")]
|
||||
// [InlineData("v10 - nested folder.cbz", "v10 - nested folder.expected.jpg")]
|
||||
// public void GetCoverImageTest(string inputFile, string expectedOutputFile)
|
||||
// {
|
||||
// var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ImageProvider");
|
||||
// var expectedBytes = File.ReadAllBytes(Path.Join(testDirectory, expectedOutputFile));
|
||||
// // TODO: Implement this with ScannerService
|
||||
// //Assert.Equal(expectedBytes, ImageProvider.GetCoverImage(Path.Join(testDirectory, inputFile)));
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
using API.Interfaces;
|
||||
using System.IO;
|
||||
using API.Interfaces;
|
||||
using API.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
||||
namespace API.Tests.Services
|
||||
{
|
||||
@ -15,6 +17,15 @@ namespace API.Tests.Services
|
||||
_scannerService = new ScannerService(_unitOfWork, _logger);
|
||||
}
|
||||
|
||||
// TODO: Start adding tests for how scanner works so we can ensure fallbacks, etc work
|
||||
[Theory]
|
||||
[InlineData("v10.cbz", "v10.expected.jpg")]
|
||||
[InlineData("v10 - with folder.cbz", "v10 - with folder.expected.jpg")]
|
||||
[InlineData("v10 - nested folder.cbz", "v10 - nested folder.expected.jpg")]
|
||||
public void GetCoverImageTest(string inputFile, string expectedOutputFile)
|
||||
{
|
||||
var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ImageProvider");
|
||||
var expectedBytes = File.ReadAllBytes(Path.Join(testDirectory, expectedOutputFile));
|
||||
Assert.Equal(expectedBytes, _scannerService.GetCoverImage(Path.Join(testDirectory, inputFile)));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
using API.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace API.Controllers
|
||||
|
@ -3,12 +3,9 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.Data;
|
||||
using API.DTOs;
|
||||
using API.Entities;
|
||||
using API.Extensions;
|
||||
using API.Interfaces;
|
||||
using API.Services;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
@ -1,11 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.Constants;
|
||||
using API.Entities;
|
||||
using API.Services;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace API.Data
|
||||
{
|
||||
@ -31,20 +31,21 @@ namespace API.Data
|
||||
|
||||
public static async Task SeedSettings(DataContext context)
|
||||
{
|
||||
// NOTE: This needs to check if settings already exists before inserting.
|
||||
// IList<ServerSetting> defaultSettings = new List<ServerSetting>()
|
||||
// {
|
||||
// new ServerSetting() {Key = "CacheDirectory", Value = CacheService.CacheDirectory}
|
||||
// };
|
||||
//
|
||||
// await context.ServerSetting.AddRangeAsync(defaultSettings);
|
||||
// await context.SaveChangesAsync();
|
||||
// await context.ServerSetting.AddAsync(new ServerSetting
|
||||
// {
|
||||
// CacheDirectory = CacheService.CacheDirectory
|
||||
// });
|
||||
//
|
||||
// await context.SaveChangesAsync();
|
||||
IList<ServerSetting> defaultSettings = new List<ServerSetting>()
|
||||
{
|
||||
new() {Key = "CacheDirectory", Value = CacheService.CacheDirectory}
|
||||
};
|
||||
var settings = await context.ServerSetting.Select(s => s).ToListAsync();
|
||||
foreach (var defaultSetting in defaultSettings)
|
||||
{
|
||||
var existing = settings.SingleOrDefault(s => s.Key == defaultSetting.Key);
|
||||
if (existing == null)
|
||||
{
|
||||
settings.Add(defaultSetting);
|
||||
}
|
||||
}
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user