1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-01-17 10:45:49 +02: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 @@ private void GivenGracePeriod(int 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.BlacklistRetryInterval).Returns(interval);
}
private void VerifyNoFailedDownloads()
@ -375,6 +376,35 @@ public void should_not_retry_if_already_failed()
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]
public void should_process_if_retry_count_is_greater_than_grace_period()
{
@ -419,7 +449,7 @@ public void should_not_process_if_age_is_less_than_grace_period()
Subject.Execute(new CheckForFinishedDownloadCommand());
VerifyNoFailedDownloads();
VerifyRetryDownload();
VerifyNoRetryDownload();
ExceptionVerification.IgnoreWarns();
}