mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-27 23:06:29 -04:00
New: Speed up mass deletes from Series Editor
* New: Speed up mass deletes from Series Editor * fixup! Additional speed up using GetAllSeriesPaths vs GetAllSeries * fixup! Tests
This commit is contained in:
@@ -6,12 +6,28 @@ using NzbDrone.Core.Languages;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles
|
||||
{
|
||||
[TestFixture]
|
||||
public class MediaFileRepositoryFixture : DbTest<MediaFileRepository, EpisodeFile>
|
||||
{
|
||||
private Series _series1;
|
||||
private Series _series2;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_series1 = Builder<Series>.CreateNew()
|
||||
.With(s => s.Id = 7)
|
||||
.Build();
|
||||
|
||||
_series2 = Builder<Series>.CreateNew()
|
||||
.With(s => s.Id = 8)
|
||||
.Build();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void get_files_by_series()
|
||||
{
|
||||
@@ -31,5 +47,30 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
seriesFiles.Should().HaveCount(4);
|
||||
seriesFiles.Should().OnlyContain(c => c.SeriesId == 12);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_delete_files_by_seriesId()
|
||||
{
|
||||
var items = Builder<EpisodeFile>.CreateListOfSize(5)
|
||||
.TheFirst(1)
|
||||
.With(c => c.SeriesId = _series2.Id)
|
||||
.TheRest()
|
||||
.With(c => c.SeriesId = _series1.Id)
|
||||
.All()
|
||||
.With(c => c.Id = 0)
|
||||
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p))
|
||||
.With(c => c.Languages = new List<Language> { Language.English })
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(items);
|
||||
|
||||
Subject.DeleteForSeries(new List<int> { _series1.Id });
|
||||
|
||||
var removedItems = Subject.GetFilesBySeries(_series1.Id);
|
||||
var nonRemovedItems = Subject.GetFilesBySeries(_series2.Id);
|
||||
|
||||
removedItems.Should().HaveCount(0);
|
||||
nonRemovedItems.Should().HaveCount(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user