mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-21 22:04:31 -04:00
New: Link indexer to specific download client
Co-authored-by: Qstick <qstick@gmail.com> (cherry picked from commit 13aaa20f1bf1448fa804738804205cb16f0d91f9) Closes #1485
This commit is contained in:
@@ -5,6 +5,7 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
@@ -67,6 +68,17 @@ namespace NzbDrone.Core.Test.Download
|
||||
return mock;
|
||||
}
|
||||
|
||||
private void WithTorrentIndexer(int downloadClientId)
|
||||
{
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.Find(It.IsAny<int>()))
|
||||
.Returns(Builder<IndexerDefinition>
|
||||
.CreateNew()
|
||||
.With(v => v.Id = _nextId++)
|
||||
.With(v => v.DownloadClientId = downloadClientId)
|
||||
.Build());
|
||||
}
|
||||
|
||||
private void GivenBlockedClient(int id)
|
||||
{
|
||||
_blockedProviders.Add(new DownloadClientStatus
|
||||
@@ -223,5 +235,39 @@ namespace NzbDrone.Core.Test.Download
|
||||
client3.Definition.Id.Should().Be(2);
|
||||
client4.Definition.Id.Should().Be(3);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_always_choose_indexer_client()
|
||||
{
|
||||
WithUsenetClient();
|
||||
WithTorrentClient();
|
||||
WithTorrentClient();
|
||||
WithTorrentClient();
|
||||
WithTorrentIndexer(3);
|
||||
|
||||
var client1 = Subject.GetDownloadClient(DownloadProtocol.Torrent, 1);
|
||||
var client2 = Subject.GetDownloadClient(DownloadProtocol.Torrent, 1);
|
||||
var client3 = Subject.GetDownloadClient(DownloadProtocol.Torrent, 1);
|
||||
var client4 = Subject.GetDownloadClient(DownloadProtocol.Torrent, 1);
|
||||
var client5 = Subject.GetDownloadClient(DownloadProtocol.Torrent, 1);
|
||||
|
||||
client1.Definition.Id.Should().Be(3);
|
||||
client2.Definition.Id.Should().Be(3);
|
||||
client3.Definition.Id.Should().Be(3);
|
||||
client4.Definition.Id.Should().Be(3);
|
||||
client5.Definition.Id.Should().Be(3);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_fail_to_choose_client_when_indexer_reference_does_not_exist()
|
||||
{
|
||||
WithUsenetClient();
|
||||
WithTorrentClient();
|
||||
WithTorrentClient();
|
||||
WithTorrentClient();
|
||||
WithTorrentIndexer(5);
|
||||
|
||||
Assert.Throws<DownloadClientUnavailableException>(() => Subject.GetDownloadClient(DownloadProtocol.Torrent, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user