Refactor user and media endpoints: remove unused GetUser and GetMedia methods, streamline AdminUserEndpoints and MediaEndpoints, and enhance metadata handling in MetadataEndpoints. Update Program.cs to remove legacy image relocation logic and improve overall code clarity.
This commit is contained in:
@@ -26,9 +26,7 @@ public class LoginCommandHandlerTests
|
||||
.Returns(Result.Success(new AuthenticatedUser(userId, "alice", "user")));
|
||||
_identityService
|
||||
.GetProfileAsync(userId, Arg.Any<CancellationToken>())
|
||||
.Returns(
|
||||
new CurrentUserProfile(userId, "alice", Guid.NewGuid(), "user", IsBlocked: false)
|
||||
);
|
||||
.Returns(new CurrentUserProfile(userId, "alice", "user", IsBlocked: false));
|
||||
_jwtTokenService
|
||||
.GenerateAccessToken(Arg.Any<AuthenticatedUser>())
|
||||
.Returns(("access-token", DateTimeOffset.UtcNow.AddMinutes(15)));
|
||||
@@ -67,9 +65,7 @@ public class LoginCommandHandlerTests
|
||||
.Returns(Result.Success(new AuthenticatedUser(userId, "alice", "user")));
|
||||
_identityService
|
||||
.GetProfileAsync(userId, Arg.Any<CancellationToken>())
|
||||
.Returns(
|
||||
new CurrentUserProfile(userId, "alice", Guid.NewGuid(), "user", IsBlocked: true)
|
||||
);
|
||||
.Returns(new CurrentUserProfile(userId, "alice", "user", IsBlocked: true));
|
||||
|
||||
var result = await CreateHandler()
|
||||
.Handle(new LoginCommand("alice", "password123"), CancellationToken.None);
|
||||
|
||||
@@ -32,9 +32,7 @@ public class RegisterCommandHandlerTests
|
||||
.Returns(Result.Success(userId));
|
||||
_identityService
|
||||
.GetProfileAsync(userId, Arg.Any<CancellationToken>())
|
||||
.Returns(
|
||||
new CurrentUserProfile(userId, "bob", Guid.NewGuid(), "user", IsBlocked: false)
|
||||
);
|
||||
.Returns(new CurrentUserProfile(userId, "bob", "user", IsBlocked: false));
|
||||
_jwtTokenService
|
||||
.GenerateAccessToken(Arg.Any<AuthenticatedUser>())
|
||||
.Returns(("access-token", DateTimeOffset.UtcNow.AddMinutes(15)));
|
||||
|
||||
@@ -9,7 +9,6 @@ using TeleWave.Application.Broadcast.RemoveChannelAd;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Application.Library.DeleteShow;
|
||||
using TeleWave.Application.Library.GetShow;
|
||||
using TeleWave.Application.Media.GetMedia;
|
||||
using TeleWave.Application.Tests.Support;
|
||||
using TeleWave.Domain.Broadcast;
|
||||
using TeleWave.Domain.Library;
|
||||
@@ -152,31 +151,6 @@ public class QueryHandlersTests
|
||||
Assert.False(missing.IsSuccess);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetMedia_ReturnsDtoOrNotFound()
|
||||
{
|
||||
var fixture = new TestDb();
|
||||
var asset = MediaAsset.Register("clip.mp4", ".mp4", MediaSource.Upload);
|
||||
await using (var seed = fixture.New())
|
||||
{
|
||||
seed.MediaAssets.Add(asset);
|
||||
await seed.SaveChangesAsync(CancellationToken.None);
|
||||
}
|
||||
|
||||
await using var db = fixture.New();
|
||||
var ok = await new GetMediaAssetQueryHandler(db).Handle(
|
||||
new GetMediaAssetQuery(asset.Id),
|
||||
CancellationToken.None
|
||||
);
|
||||
Assert.True(ok.IsSuccess);
|
||||
|
||||
var missing = await new GetMediaAssetQueryHandler(db).Handle(
|
||||
new GetMediaAssetQuery(Guid.NewGuid()),
|
||||
CancellationToken.None
|
||||
);
|
||||
Assert.False(missing.IsSuccess);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeleteShow_RemovesOrNotFound()
|
||||
{
|
||||
|
||||
@@ -30,12 +30,8 @@ public class FindMissingEpisodesTests
|
||||
}
|
||||
|
||||
var provider = Substitute.For<IMetadataProvider>();
|
||||
provider
|
||||
.GetSeasonEpisodeCountAsync("123", 1, Arg.Any<CancellationToken>())
|
||||
.Returns(5);
|
||||
provider
|
||||
.GetSeasonEpisodeCountAsync("123", 2, Arg.Any<CancellationToken>())
|
||||
.Returns(3);
|
||||
provider.GetSeasonEpisodeCountAsync("123", 1, Arg.Any<CancellationToken>()).Returns(5);
|
||||
provider.GetSeasonEpisodeCountAsync("123", 2, Arg.Any<CancellationToken>()).Returns(3);
|
||||
var resolver = Substitute.For<IMetadataProviderResolver>();
|
||||
resolver.Resolve("tmdb").Returns(provider);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user