Files
Musify/backend/Tests/Musify.Application.Tests/Mixes/GetMixByIdQueryHandlerTests.cs
T
Admin 31032bd8e8 Remove YouTube integration from backend and deployment config
Drops the YouTube-backed second catalog source entirely: the
Local/External split on Track/Album collapses into single concrete
entities, Artist/TrackArtist/ExternalTrack/ExternalAlbum and the
YouTube service/download pipeline (yt-dlp, MassTransit consumer,
routing slip) are deleted, and mixes now source discovery only from
local listening history. Includes the RemoveYouTubeIntegration EF
Core migration and matching Worker/deploy/compose cleanup (no more
yt-dlp/python/deno in the Worker image, no thumbnail-cache/YtDlp
config sections).
2026-09-15 21:17:03 +02:00

51 lines
1.9 KiB
C#

using ErrorOr;
using Musify.Application.Mixes;
using Musify.Application.Tests.TestSupport;
using Xunit;
namespace Musify.Application.Tests.Mixes
{
public sealed class GetMixByIdQueryHandlerTests : HandlerTestBase
{
private GetMixByIdQueryHandler CreateHandler() => new(Database);
[Fact]
public async Task Handle_OwnedMix_ReturnsItWithOrderedItems()
{
var owner = TestEntities.User();
var firstTrack = TestEntities.Track(owner, "First");
var secondTrack = TestEntities.Track(owner, "Second");
var mix = TestEntities.Mix(owner.Id, "Discovery");
var second = TestEntities.MixItem(mix.Id, secondTrack.Id, position: 1);
var first = TestEntities.MixItem(mix.Id, firstTrack.Id, position: 0);
await SeedAsync(owner, firstTrack, secondTrack, mix, second, first);
var result = await CreateHandler().Handle(new GetMixByIdQuery(owner.Id, mix.Id), TestContext.Current.CancellationToken);
Assert.False(result.IsError);
Assert.Equal("Discovery", result.Value.Title);
Assert.Equal(["First", "Second"], result.Value.Items.Select(item => item.Title));
}
[Fact]
public async Task Handle_MixMissing_ReturnsNotFound()
{
var result = await CreateHandler().Handle(new GetMixByIdQuery(1, Guid.NewGuid()), TestContext.Current.CancellationToken);
Assert.Equal(ErrorType.NotFound, result.FirstError.Type);
}
[Fact]
public async Task Handle_MixBelongsToAnotherUser_ReturnsNotFound()
{
var owner = TestEntities.User(1, "owner");
var mix = TestEntities.Mix(owner.Id);
await SeedAsync(owner, mix);
var result = await CreateHandler().Handle(new GetMixByIdQuery(2, mix.Id), TestContext.Current.CancellationToken);
Assert.Equal(ErrorType.NotFound, result.FirstError.Type);
}
}
}