Refactor media import handlers to utilize ManualInboxTaker for improved functionality
Updated the ImportManualInboxCommandHandler and ImportMoviesCommandHandler to replace direct storage interactions with the ManualInboxTaker, streamlining the import process. This change enhances code clarity and maintains consistency across media import functionalities. Additionally, refactored related tests to accommodate the new handler structure, ensuring robust testing of the import logic.
This commit is contained in:
1 parent
287ed5aa12
commit
6ca629c13a
10 files changed
+204
-219
No files matched your search
@@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using NSubstitute;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Application.Library.Genres;
|
||||
using TeleWave.Application.Media.ManualInbox;
|
||||
using TeleWave.Application.Media.MovieImport;
|
||||
using TeleWave.Application.Metadata;
|
||||
using TeleWave.Application.Tests.Support;
|
||||
@@ -64,10 +65,12 @@ public class ImportMoviesTests
|
||||
new GenreMatcher(db)
|
||||
);
|
||||
|
||||
var result = await new ImportMoviesCommandHandler(db, storage, queue, applier).Handle(
|
||||
new ImportMoviesCommand(items, Provider),
|
||||
CancellationToken.None
|
||||
);
|
||||
var result = await new ImportMoviesCommandHandler(
|
||||
db,
|
||||
new ManualInboxTaker(db, storage),
|
||||
queue,
|
||||
applier
|
||||
).Handle(new ImportMoviesCommand(items, Provider), CancellationToken.None);
|
||||
|
||||
Assert.True(result.IsSuccess);
|
||||
await db.SaveChangesAsync(CancellationToken.None);
|
||||
|
||||
@@ -37,7 +37,7 @@ public sealed class ManualInboxIntegrationTests(PostgresFixture fixture)
|
||||
await using var db = fixture.CreateContext();
|
||||
var result = await new ImportManualInboxCommandHandler(
|
||||
db,
|
||||
storage,
|
||||
new ManualInboxTaker(db, storage),
|
||||
Substitute.For<IMediaProcessingQueue>()
|
||||
).Handle(
|
||||
new ImportManualInboxCommand(
|
||||
@@ -107,7 +107,7 @@ public sealed class ManualInboxIntegrationTests(PostgresFixture fixture)
|
||||
await using var db = fixture.CreateContext();
|
||||
var result = await new ImportManualInboxCommandHandler(
|
||||
db,
|
||||
storage,
|
||||
new ManualInboxTaker(db, storage),
|
||||
Substitute.For<IMediaProcessingQueue>()
|
||||
).Handle(
|
||||
new ImportManualInboxCommand(
|
||||
@@ -142,7 +142,7 @@ public sealed class ManualInboxIntegrationTests(PostgresFixture fixture)
|
||||
await using var db = fixture.CreateContext();
|
||||
var result = await new ImportManualInboxCommandHandler(
|
||||
db,
|
||||
storage,
|
||||
new ManualInboxTaker(db, storage),
|
||||
Substitute.For<IMediaProcessingQueue>()
|
||||
).Handle(
|
||||
new ImportManualInboxCommand([new ManualImportItem(name, 4, 12)], showId),
|
||||
|
||||
Reference in new issue
Block a user