From d13246e6a0b57367e4d08d3755a7b91425d3a1ff Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Sun, 1 Nov 2026 10:41:51 +0200 Subject: [PATCH] Fixes the flaky LibraryPathTemplate equality and TranscodingCacheCoordinator touch tests --- .../Playback/TranscodingCacheCoordinatorTests.cs | 6 ++++-- .../ValueObjects/LibraryPathTemplateTests.cs | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/IntegrationTests/Lumina.Infrastructure.IntegrationTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Playback/TranscodingCacheCoordinatorTests.cs b/tests/IntegrationTests/Lumina.Infrastructure.IntegrationTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Playback/TranscodingCacheCoordinatorTests.cs index eb08063b..d8626467 100644 --- a/tests/IntegrationTests/Lumina.Infrastructure.IntegrationTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Playback/TranscodingCacheCoordinatorTests.cs +++ b/tests/IntegrationTests/Lumina.Infrastructure.IntegrationTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Playback/TranscodingCacheCoordinatorTests.cs @@ -449,11 +449,13 @@ public class TranscodingCacheCoordinatorTests : IDisposable string cacheId = CreateCacheId(); string cachePath = Path.Combine(_cacheRoot, cacheId); 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 _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.False(result); diff --git a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/ValueObjects/LibraryPathTemplateTests.cs b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/ValueObjects/LibraryPathTemplateTests.cs index e9a51976..d9c7ad43 100644 --- a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/ValueObjects/LibraryPathTemplateTests.cs +++ b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/ValueObjects/LibraryPathTemplateTests.cs @@ -14,6 +14,7 @@ namespace Lumina.Domain.UnitTests.Core.BoundedContexts.LibraryManagementBoundedC public class LibraryPathTemplateTests { private readonly LibraryPathTemplateFixture _libraryPathTemplateFixture = new(); + private readonly LibraryPathPartFixture _libraryPathPartFixture = new(); [Fact] public void Create_WhenCalledWithParts_ShouldCreateTemplateWithThoseParts() @@ -75,7 +76,8 @@ public class LibraryPathTemplateTests LibraryPathTemplate firstTemplate = _libraryPathTemplateFixture.Create(); // 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.NotEqual(firstTemplate, secondTemplate);