From 7116167ea7352a67a3a3a71caf862d175677f1a2 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Thu, 28 Aug 2014 21:42:01 +0200 Subject: [PATCH] Added additional test to check retry interval. --- .../Download/FailedDownloadServiceFixture.cs | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core.Test/Download/FailedDownloadServiceFixture.cs b/src/NzbDrone.Core.Test/Download/FailedDownloadServiceFixture.cs index d653c84ac..0898c64aa 100644 --- a/src/NzbDrone.Core.Test/Download/FailedDownloadServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Download/FailedDownloadServiceFixture.cs @@ -93,9 +93,10 @@ namespace NzbDrone.Core.Test.Download Mocker.GetMock().SetupGet(s => s.BlacklistGracePeriod).Returns(hours); } - private void GivenRetryLimit(int count) + private void GivenRetryLimit(int count, int interval = 5) { Mocker.GetMock().SetupGet(s => s.BlacklistRetryLimit).Returns(count); + Mocker.GetMock().SetupGet(s => s.BlacklistRetryInterval).Returns(interval); } private void VerifyNoFailedDownloads() @@ -375,6 +376,35 @@ namespace NzbDrone.Core.Test.Download VerifyNoRetryDownload(); } + [Test] + public void should_retry_if_interval_expired() + { + GivenFailedDownloadClientHistory(); + + var historyGrabbed = Builder.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] 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()); VerifyNoFailedDownloads(); - VerifyRetryDownload(); + VerifyNoRetryDownload(); ExceptionVerification.IgnoreWarns(); }