Merge branch 'master' into bugfix/fixes-return-url-missing-on-redirect-to-login-page

This commit is contained in:
BinaryAlley authored and GitHub committed 2026-11-01 11:08:40 +02:00
commit 235c2ef9ea
6 files changed
+22 -43

No files matched your search

@@ -23,14 +23,6 @@ public interface IBookRepository : IRepository<BookEntity>,
IGetAllLiteRepositoryAction<BookEntity, BookLiteRow>, IGetAllLiteRepositoryAction<BookEntity, BookLiteRow>,
IDeleteByIdRepositoryAction<Guid> IDeleteByIdRepositoryAction<Guid>
{ {
/// <summary>
/// Gets all the books of the media library identified by <paramref name="libraryId"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose books are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either a collection of <see cref="BookEntity"/>, or an error.</returns>
Task<Result<IEnumerable<BookEntity>>> GetByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Gets the book of the media library identified by <paramref name="libraryId"/> that is stored at the provided <paramref name="path"/>. /// Gets the book of the media library identified by <paramref name="libraryId"/> that is stored at the provided <paramref name="path"/>.
/// </summary> /// </summary>
@@ -269,25 +269,6 @@ internal sealed class BookRepository : IBookRepository
}; };
} }
/// <summary>
/// Gets all the books of the media library identified by <paramref name="libraryId"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose books are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either a collection of <see cref="BookEntity"/>, or an error.</returns>
public async Task<Result<IEnumerable<BookEntity>>> GetByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken)
{
return await _luminaDbContext.Books
.Include(book => book.Tags)
.Include(book => book.Genres)
.Include(book => book.ISBNs)
.Include(book => book.Contributors)
.Include(book => book.Artwork)
.AsSplitQuery()
.Where(book => book.LibraryId == libraryId)
.ToListAsync(cancellationToken).ConfigureAwait(false);
}
/// <summary> /// <summary>
/// Gets the book of the media library identified by <paramref name="libraryId"/> that is stored at the provided <paramref name="path"/>. /// Gets the book of the media library identified by <paramref name="libraryId"/> that is stored at the provided <paramref name="path"/>.
/// </summary> /// </summary>
@@ -449,11 +449,13 @@ public class TranscodingCacheCoordinatorTests : IDisposable
string cacheId = CreateCacheId(); string cacheId = CreateCacheId();
string cachePath = Path.Combine(_cacheRoot, cacheId); string cachePath = Path.Combine(_cacheRoot, cacheId);
PublishEntry(cacheId, 50, 100); PublishEntry(cacheId, 50, 100);
Thread.Sleep(200); // The entry must be older than the grace period before the touch, and the touch must still be inside it when the reservation
// runs. A grace period of seconds keeps the second condition true on slow CI runners, where a few hundred milliseconds can pass between the two calls.
Thread.Sleep(2100);
// Act // Act
_sut.Touch(cacheId, TimeSpan.Zero); _sut.Touch(cacheId, TimeSpan.Zero);
bool result = _sut.TryReserve(80, 100, TimeSpan.FromMilliseconds(100), out _); bool result = _sut.TryReserve(80, 100, TimeSpan.FromSeconds(2), out _);
// Assert // Assert
Assert.False(result); Assert.False(result);
@@ -43,7 +43,8 @@ public class FileHashServiceTests
shouldParallelizeReads: true, shouldParallelizeReads: true,
() => () =>
{ {
callbackInvocationCount++; // The callback is invoked concurrently by the parallel reads, so a plain increment could lose a count.
Interlocked.Increment(ref callbackInvocationCount);
return Task.CompletedTask; return Task.CompletedTask;
}, },
CancellationToken.None); CancellationToken.None);
@@ -262,7 +262,7 @@ public class BookRepositoryTests
} }
[Fact] [Fact]
public async Task GetByLibraryIdAsync_WhenCalled_ShouldReturnOnlyBooksOfTheLibrary() public async Task GetAllAsync_WhenOtherLibrariesHaveBooks_ShouldReturnOnlyBooksOfTheFilteredLibrary()
{ {
// Arrange // Arrange
Guid libraryId = Guid.NewGuid(); Guid libraryId = Guid.NewGuid();
@@ -272,13 +272,14 @@ public class BookRepositoryTests
bookOfAnotherLibrary.LibraryId = Guid.NewGuid(); bookOfAnotherLibrary.LibraryId = Guid.NewGuid();
_mockContext.Books.AddRange(bookOfLibrary, bookOfAnotherLibrary); _mockContext.Books.AddRange(bookOfLibrary, bookOfAnotherLibrary);
await _mockContext.SaveChangesAsync(); await _mockContext.SaveChangesAsync();
LibraryFilterDto filter = _libraryFilterDtoFixture.Create(libraryId: libraryId);
// Act // Act
Result<IEnumerable<BookEntity>> result = await _sut.GetByLibraryIdAsync(libraryId, CancellationToken.None); Result<PaginatedResultDto<BookEntity>> result = await _sut.GetAllAsync<LibraryFilterDto>(filterModel: filter, cancellationToken: CancellationToken.None);
// Assert // Assert
Assert.False(result.IsFailure); Assert.False(result.IsFailure);
BookEntity retrievedBook = Assert.Single(result.Value); BookEntity retrievedBook = Assert.Single(result.Value.Data);
Assert.Equal(bookOfLibrary.Id, retrievedBook.Id); Assert.Equal(bookOfLibrary.Id, retrievedBook.Id);
} }
@@ -1544,8 +1545,8 @@ public class BookRepositoryTests
public async Task GetByIdsAsync_WhenExactlyFiveHundredIdsAreRequested_ShouldReturnEveryBook() public async Task GetByIdsAsync_WhenExactlyFiveHundredIdsAreRequested_ShouldReturnEveryBook()
{ {
// Arrange // Arrange
const int bookCount = 500; const int BOOK_COUNT = 500;
List<BookEntity> books = CreateBooks(bookCount); List<BookEntity> books = CreateBooks(BOOK_COUNT);
_mockContext.Books.AddRange(books); _mockContext.Books.AddRange(books);
await _mockContext.SaveChangesAsync(); await _mockContext.SaveChangesAsync();
@@ -1555,7 +1556,7 @@ public class BookRepositoryTests
// Assert // Assert
Assert.False(result.IsFailure); Assert.False(result.IsFailure);
Assert.Equal(bookCount, result.Value.Count); Assert.Equal(BOOK_COUNT, result.Value.Count);
Assert.Equal( Assert.Equal(
books.Select(book => book.Id).OrderBy(id => id), books.Select(book => book.Id).OrderBy(id => id),
result.Value.Select(book => book.Id).OrderBy(id => id)); result.Value.Select(book => book.Id).OrderBy(id => id));
@@ -1565,8 +1566,8 @@ public class BookRepositoryTests
public async Task GetByIdsAsync_WhenMoreThanFiveHundredIdsAreRequested_ShouldReturnEveryBook() public async Task GetByIdsAsync_WhenMoreThanFiveHundredIdsAreRequested_ShouldReturnEveryBook()
{ {
// Arrange // Arrange
const int bookCount = 501; const int BOOK_COUNT = 501;
List<BookEntity> books = CreateBooks(bookCount); List<BookEntity> books = CreateBooks(BOOK_COUNT);
_mockContext.Books.AddRange(books); _mockContext.Books.AddRange(books);
await _mockContext.SaveChangesAsync(); await _mockContext.SaveChangesAsync();
@@ -1576,7 +1577,7 @@ public class BookRepositoryTests
// Assert // Assert
Assert.False(result.IsFailure); Assert.False(result.IsFailure);
Assert.Equal(bookCount, result.Value.Count); Assert.Equal(BOOK_COUNT, result.Value.Count);
Assert.Equal( Assert.Equal(
books.Select(book => book.Id).OrderBy(id => id), books.Select(book => book.Id).OrderBy(id => id),
result.Value.Select(book => book.Id).OrderBy(id => id)); result.Value.Select(book => book.Id).OrderBy(id => id));
@@ -1656,8 +1657,8 @@ public class BookRepositoryTests
public async Task GetAuthorsDisplayNamesByBookIdsAsync_WhenMoreThanFiveHundredIdsAreRequested_ShouldReturnTheAuthorOfEveryRequestedBook() public async Task GetAuthorsDisplayNamesByBookIdsAsync_WhenMoreThanFiveHundredIdsAreRequested_ShouldReturnTheAuthorOfEveryRequestedBook()
{ {
// Arrange // Arrange
const int bookCount = 501; const int BOOK_COUNT = 501;
List<BookEntity> books = CreateBooks(bookCount); List<BookEntity> books = CreateBooks(BOOK_COUNT);
_mockContext.Books.AddRange(books); _mockContext.Books.AddRange(books);
MediaContributorEntity author = _mediaContributorEntityFixture.Create(displayName: "Shared Author"); MediaContributorEntity author = _mediaContributorEntityFixture.Create(displayName: "Shared Author");
_mockContext.MediaContributors.Add(author); _mockContext.MediaContributors.Add(author);
@@ -1673,7 +1674,7 @@ public class BookRepositoryTests
// Assert // Assert
Assert.False(result.IsFailure); Assert.False(result.IsFailure);
Assert.Equal(bookCount, result.Value.Count); Assert.Equal(BOOK_COUNT, result.Value.Count);
Assert.All(result.Value.Keys, bookId => Assert.Equal("Shared Author", result.Value[bookId])); Assert.All(result.Value.Keys, bookId => Assert.Equal("Shared Author", result.Value[bookId]));
} }
@@ -14,6 +14,7 @@ namespace Lumina.Domain.UnitTests.Core.BoundedContexts.LibraryManagementBoundedC
public class LibraryPathTemplateTests public class LibraryPathTemplateTests
{ {
private readonly LibraryPathTemplateFixture _libraryPathTemplateFixture = new(); private readonly LibraryPathTemplateFixture _libraryPathTemplateFixture = new();
private readonly LibraryPathPartFixture _libraryPathPartFixture = new();
[Fact] [Fact]
public void Create_WhenCalledWithParts_ShouldCreateTemplateWithThoseParts() public void Create_WhenCalledWithParts_ShouldCreateTemplateWithThoseParts()
@@ -75,7 +76,8 @@ public class LibraryPathTemplateTests
LibraryPathTemplate firstTemplate = _libraryPathTemplateFixture.Create(); LibraryPathTemplate firstTemplate = _libraryPathTemplateFixture.Create();
// Act // Act
LibraryPathTemplate secondTemplate = _libraryPathTemplateFixture.Create(); // The second template extends the first one, because two random templates can be identical (a single typed part of the same kind).
LibraryPathTemplate secondTemplate = LibraryPathTemplate.Create([.. firstTemplate.Parts, _libraryPathPartFixture.Create()]);
// Assert // Assert
Assert.NotEqual(firstTemplate, secondTemplate); Assert.NotEqual(firstTemplate, secondTemplate);