Build ErsatzTV Image / CI image pin matches docker/ci (pull_request) Successful in 6s
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 10s
Build ErsatzTV Image / decisions.md append-only (pull_request) Successful in 21s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 13m34s
Build ErsatzTV Image / Functional E2E (curl contracts) (pull_request) Successful in 15m21s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 16m19s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 19m36s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 19m37s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Independent review found a blocker + two mediums: - BLOCKER: SearchSmartCollections/SearchMultiCollections (the scheduling collection picker) didn't filter OwnedByChannelId, so a user could select a system-owned auto-tune artifact into their own schedule item — a later channel delete would then cascade-delete that schedule item (ProgramScheduleItem-> MultiCollection is OnDelete(Cascade)). Both handlers now exclude owned rows; regression test added (CollectionPickerHidesOwnedTests). - MEDIUM: TryStampOwnership now runs on CancellationToken.None (post-commit convention #254) and stamps the MC + member SmartCollections in one transaction, so a late cancel or mid-way failure can't leave a permanent orphan / list leak. - Documented the movie-remainder weight clamp bound (>1000 un-touched movies can't express the exact ratio — the 1..1000 weight-column bound from #70). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
61 lines
2.2 KiB
C#
61 lines
2.2 KiB
C#
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using ErsatzTV.Application.MediaCollections;
|
|
using ErsatzTV.Application.Search;
|
|
using ErsatzTV.Core.Domain;
|
|
using ErsatzTV.Infrastructure.Data;
|
|
using ErsatzTV.Tests.Support;
|
|
using NUnit.Framework;
|
|
using Shouldly;
|
|
|
|
namespace ErsatzTV.Tests.Application.Search;
|
|
|
|
// #425: the scheduling collection picker (search-smart/multi-collections) must NOT surface the
|
|
// system-owned weighted-auto-tune artifacts — selecting one into a user schedule would let a later
|
|
// channel delete cascade away that schedule item.
|
|
[TestFixture]
|
|
public class CollectionPickerHidesOwnedTests
|
|
{
|
|
private InMemoryTvContext _db = null!;
|
|
|
|
[SetUp]
|
|
public async Task SetUp() => _db = await InMemoryTvContext.CreateAsync();
|
|
|
|
[TearDown]
|
|
public async Task TearDown() => await _db.DisposeAsync();
|
|
|
|
[Test]
|
|
public async Task SearchSmartCollections_Excludes_Owned()
|
|
{
|
|
await using (TvContext ctx = _db.CreateContext())
|
|
{
|
|
ctx.SmartCollections.Add(new SmartCollection { Name = "at:tok:0", Query = "q", OwnedByChannelId = 5 });
|
|
ctx.SmartCollections.Add(new SmartCollection { Name = "at:user:sc", Query = "q" });
|
|
await ctx.SaveChangesAsync();
|
|
}
|
|
|
|
var result = await new SearchSmartCollectionsHandler(_db.Factory)
|
|
.Handle(new SearchSmartCollections("at"), CancellationToken.None);
|
|
|
|
result.ShouldContain(vm => vm.Name == "at:user:sc");
|
|
result.ShouldNotContain(vm => vm.Name == "at:tok:0");
|
|
}
|
|
|
|
[Test]
|
|
public async Task SearchMultiCollections_Excludes_Owned()
|
|
{
|
|
await using (TvContext ctx = _db.CreateContext())
|
|
{
|
|
ctx.MultiCollections.Add(new MultiCollection { Name = "at-mc:tok", OwnedByChannelId = 5 });
|
|
ctx.MultiCollections.Add(new MultiCollection { Name = "at-mc:user" });
|
|
await ctx.SaveChangesAsync();
|
|
}
|
|
|
|
var result = await new SearchMultiCollectionsHandler(_db.Factory)
|
|
.Handle(new SearchMultiCollections("at"), CancellationToken.None);
|
|
|
|
result.ShouldContain(vm => vm.Name == "at-mc:user");
|
|
result.ShouldNotContain(vm => vm.Name == "at-mc:tok");
|
|
}
|
|
}
|