1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-27 10:17:47 +00:00

Added additional test to check retry interval.

This commit is contained in:
Taloth Saldono 2014-08-28 21:42:01 +02:00
parent 1bca66a0c2
commit 7116167ea7

View file

@ -93,9 +93,10 @@ namespace NzbDrone.Core.Test.Download
Mocker.GetMock<IConfigService>().SetupGet(s => s.BlacklistGracePeriod).Returns(hours); Mocker.GetMock<IConfigService>().SetupGet(s => s.BlacklistGracePeriod).Returns(hours);
} }
private void GivenRetryLimit(int count) private void GivenRetryLimit(int count, int interval = 5)
{ {
Mocker.GetMock<IConfigService>().SetupGet(s => s.BlacklistRetryLimit).Returns(count); Mocker.GetMock<IConfigService>().SetupGet(s => s.BlacklistRetryLimit).Returns(count);
Mocker.GetMock<IConfigService>().SetupGet(s => s.BlacklistRetryInterval).Returns(interval);
} }
private void VerifyNoFailedDownloads() private void VerifyNoFailedDownloads()
@ -375,6 +376,35 @@ namespace NzbDrone.Core.Test.Download
VerifyNoRetryDownload(); VerifyNoRetryDownload();
} }
[Test]
public void should_retry_if_interval_expired()
{
GivenFailedDownloadClientHistory();
var historyGrabbed = Builder<History.History>.CreateListOfSize(1)
.Build()
.ToList();
historyGrabbed.First().Data.Add("downloadClient", "SabnzbdClient");
historyGrabbed.First().Data.Add("downloadClientId", _failed.First().DownloadClientId);
historyGrabbed.First().Data.Add("ageHours", "1");
GivenGrabbedHistory(historyGrabbed);
GivenNoFailedHistory();
GivenGracePeriod(6);
GivenRetryLimit(1);
Subject.Execute(new CheckForFinishedDownloadCommand());
Subject.GetTrackedDownloads().First().LastRetry -= TimeSpan.FromMinutes(10);
Subject.Execute(new CheckForFinishedDownloadCommand());
VerifyRetryDownload();
ExceptionVerification.IgnoreWarns();
}
[Test] [Test]
public void should_process_if_retry_count_is_greater_than_grace_period() public void should_process_if_retry_count_is_greater_than_grace_period()
{ {
@ -419,7 +449,7 @@ namespace NzbDrone.Core.Test.Download
Subject.Execute(new CheckForFinishedDownloadCommand()); Subject.Execute(new CheckForFinishedDownloadCommand());
VerifyNoFailedDownloads(); VerifyNoFailedDownloads();
VerifyRetryDownload(); VerifyNoRetryDownload();
ExceptionVerification.IgnoreWarns(); ExceptionVerification.IgnoreWarns();
} }