mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-24 22:36:19 -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:
+53
@@ -0,0 +1,53 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Download.History;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.DownloadHistoryTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class DownloadHistoryRepositoryFixture : DbTest<DownloadHistoryRepository, DownloadHistory>
|
||||
{
|
||||
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 should_delete_history_items_by_seriesId()
|
||||
{
|
||||
var items = Builder<DownloadHistory>.CreateListOfSize(5)
|
||||
.TheFirst(1)
|
||||
.With(c => c.Id = 0)
|
||||
.With(c => c.SeriesId = _series2.Id)
|
||||
.TheRest()
|
||||
.With(c => c.Id = 0)
|
||||
.With(c => c.SeriesId = _series1.Id)
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(items);
|
||||
|
||||
Subject.DeleteBySeriesIds(new List<int> { _series1.Id });
|
||||
|
||||
var removedItems = Subject.All().Where(h => h.SeriesId == _series1.Id);
|
||||
var nonRemovedItems = Subject.All().Where(h => h.SeriesId == _series2.Id);
|
||||
|
||||
removedItems.Should().HaveCount(0);
|
||||
nonRemovedItems.Should().HaveCount(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@@ -320,7 +320,7 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads
|
||||
.Setup(s => s.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<int>(), null))
|
||||
.Returns(default(RemoteEpisode));
|
||||
|
||||
Subject.Handle(new SeriesDeletedEvent(remoteEpisode.Series, true, true));
|
||||
Subject.Handle(new SeriesDeletedEvent(new List<Series> { remoteEpisode.Series }, true, true));
|
||||
|
||||
var trackedDownloads = Subject.GetTrackedDownloads();
|
||||
trackedDownloads.Should().HaveCount(1);
|
||||
|
||||
Reference in New Issue
Block a user