Skip to content

Commit

Permalink
Basic Metadata Polish (#3548)
Browse files Browse the repository at this point in the history
  • Loading branch information
majora2007 authored Feb 14, 2025
1 parent c0b59d8 commit 4c44dbf
Show file tree
Hide file tree
Showing 20 changed files with 3,515 additions and 386 deletions.
7 changes: 5 additions & 2 deletions API.Tests/AbstractDbTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public abstract class AbstractDbTest : IDisposable
protected readonly DbConnection _connection;
protected readonly DataContext _context;
protected readonly IUnitOfWork _unitOfWork;
protected readonly IMapper _mapper;


protected const string CacheDirectory = "C:/kavita/config/cache/";
Expand All @@ -42,6 +43,7 @@ protected AbstractDbTest()
{
var contextOptions = new DbContextOptionsBuilder<DataContext>()
.UseSqlite(CreateInMemoryDatabase())
.EnableSensitiveDataLogging()
.Options;

_connection = RelationalOptionsExtension.Extract(contextOptions).Connection;
Expand All @@ -53,10 +55,10 @@ protected AbstractDbTest()
Task.Run(SeedDb).GetAwaiter().GetResult();

var config = new MapperConfiguration(cfg => cfg.AddProfile<AutoMapperProfiles>());
var mapper = config.CreateMapper();
_mapper = config.CreateMapper();

GlobalConfiguration.Configuration.UseInMemoryStorage();
_unitOfWork = new UnitOfWork(_context, mapper, null);
_unitOfWork = new UnitOfWork(_context, _mapper, null);
}

private static DbConnection CreateInMemoryDatabase()
Expand Down Expand Up @@ -92,6 +94,7 @@ private async Task<bool> SeedDb()


_context.Library.Add(new LibraryBuilder("Manga")
.WithAllowMetadataMatching(true)
.WithFolderPath(new FolderPathBuilder(DataDirectory).Build())
.Build());

Expand Down
4 changes: 2 additions & 2 deletions API.Tests/Extensions/SeriesFilterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -932,11 +932,11 @@ private async Task<AppUser> SetupHasRating()

var seriesService = new SeriesService(_unitOfWork, Substitute.For<IEventHub>(),
Substitute.For<ITaskScheduler>(), Substitute.For<ILogger<SeriesService>>(),
Substitute.For<IScrobblingService>(), Substitute.For<ILocalizationService>()
, Substitute.For<IImageService>());
Substitute.For<IScrobblingService>(), Substitute.For<ILocalizationService>());

// Select 0 Rating
var zeroRating = await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(2);
Assert.NotNull(zeroRating);

Assert.True(await seriesService.UpdateRating(user, new UpdateSeriesRatingDto()
{
Expand Down
18 changes: 18 additions & 0 deletions API.Tests/Helpers/StringHelperTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using API.Helpers;
using Xunit;

namespace API.Tests.Helpers;

public class StringHelperTests
{
[Theory]
[InlineData(
"<p>A Perfect Marriage Becomes a Perfect Affair!<br /> <br><br><br /> Every woman wishes for that happily ever after, but when time flies by and you've become a neglected housewife, what's a woman to do?</p>",
"<p>A Perfect Marriage Becomes a Perfect Affair!<br /> Every woman wishes for that happily ever after, but when time flies by and you've become a neglected housewife, what's a woman to do?</p>"
)]
public void Test(string input, string expected)
{
Assert.Equal(expected, StringHelper.SquashBreaklines(input));
}
}
Loading

0 comments on commit 4c44dbf

Please sign in to comment.