mirror of
https://github.com/Radarr/Radarr.git
synced 2025-04-24 22:47:05 -04:00
New: FutureDownloadClient Housekeeper Tests
This commit is contained in:
parent
fe591816bb
commit
fd87be6d1e
3 changed files with 123 additions and 5 deletions
|
@ -220,12 +220,15 @@ stages:
|
||||||
Linux:
|
Linux:
|
||||||
osName: 'Linux'
|
osName: 'Linux'
|
||||||
imageName: 'ubuntu-16.04'
|
imageName: 'ubuntu-16.04'
|
||||||
|
failBuild: true
|
||||||
Mac:
|
Mac:
|
||||||
osName: 'Mac'
|
osName: 'Mac'
|
||||||
imageName: 'macos-10.13'
|
imageName: 'macos-10.13'
|
||||||
|
failBuild: false
|
||||||
Windows:
|
Windows:
|
||||||
osName: 'Windows'
|
osName: 'Windows'
|
||||||
imageName: 'vs2017-win2016'
|
imageName: 'vs2017-win2016'
|
||||||
|
failBuild: true
|
||||||
|
|
||||||
pool:
|
pool:
|
||||||
vmImage: $(imageName)
|
vmImage: $(imageName)
|
||||||
|
@ -267,7 +270,7 @@ stages:
|
||||||
testResultsFormat: 'NUnit'
|
testResultsFormat: 'NUnit'
|
||||||
testResultsFiles: '**/TestResult.xml'
|
testResultsFiles: '**/TestResult.xml'
|
||||||
testRunTitle: '$(osName) Unit Tests'
|
testRunTitle: '$(osName) Unit Tests'
|
||||||
failTaskOnFailedTests: true
|
failTaskOnFailedTests: $(failBuild)
|
||||||
|
|
||||||
- stage: Integration_Automation
|
- stage: Integration_Automation
|
||||||
displayName: Integration / Automation
|
displayName: Integration / Automation
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using Radarr.Http.Extensions;
|
|
||||||
using NzbDrone.Core.Datastore.Events;
|
using NzbDrone.Core.Datastore.Events;
|
||||||
using NzbDrone.Core.MediaCover;
|
using NzbDrone.Core.MediaCover;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
@ -14,8 +12,6 @@ using NzbDrone.Core.Movies.Events;
|
||||||
using NzbDrone.Core.Validation.Paths;
|
using NzbDrone.Core.Validation.Paths;
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
using NzbDrone.SignalR;
|
using NzbDrone.SignalR;
|
||||||
using NzbDrone.Core.Datastore;
|
|
||||||
using Microsoft.CSharp.RuntimeBinder;
|
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using Radarr.Http;
|
using Radarr.Http;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using FizzWare.NBuilder;
|
||||||
|
using Moq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.Download;
|
||||||
|
using NzbDrone.Core.Housekeeping.Housekeepers;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using NzbDrone.Core.ThingiProvider.Status;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class FixFutureDownloadClientStatusTimesFixture : CoreTest<FixFutureDownloadClientStatusTimes>
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void should_set_disabled_till_when_its_too_far_in_the_future()
|
||||||
|
{
|
||||||
|
var disabledTillTime = EscalationBackOff.Periods[1];
|
||||||
|
var downloadClientStatuses = Builder<DownloadClientStatus>.CreateListOfSize(5)
|
||||||
|
.All()
|
||||||
|
.With(t => t.DisabledTill = DateTime.UtcNow.AddDays(5))
|
||||||
|
.With(t => t.InitialFailure = DateTime.UtcNow.AddDays(-5))
|
||||||
|
.With(t => t.MostRecentFailure = DateTime.UtcNow.AddDays(-5))
|
||||||
|
.With(t => t.EscalationLevel = 1)
|
||||||
|
.BuildListOfNew();
|
||||||
|
|
||||||
|
Mocker.GetMock<IDownloadClientStatusRepository>()
|
||||||
|
.Setup(s => s.All())
|
||||||
|
.Returns(downloadClientStatuses);
|
||||||
|
|
||||||
|
Subject.Clean();
|
||||||
|
|
||||||
|
Mocker.GetMock<IDownloadClientStatusRepository>()
|
||||||
|
.Verify(v => v.UpdateMany(
|
||||||
|
It.Is<List<DownloadClientStatus>>(i => i.All(
|
||||||
|
s => s.DisabledTill.Value <= DateTime.UtcNow.AddMinutes(disabledTillTime)))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_set_initial_failure_when_its_in_the_future()
|
||||||
|
{
|
||||||
|
var downloadClientStatuses = Builder<DownloadClientStatus>.CreateListOfSize(5)
|
||||||
|
.All()
|
||||||
|
.With(t => t.DisabledTill = DateTime.UtcNow.AddDays(-5))
|
||||||
|
.With(t => t.InitialFailure = DateTime.UtcNow.AddDays(5))
|
||||||
|
.With(t => t.MostRecentFailure = DateTime.UtcNow.AddDays(-5))
|
||||||
|
.With(t => t.EscalationLevel = 1)
|
||||||
|
.BuildListOfNew();
|
||||||
|
|
||||||
|
Mocker.GetMock<IDownloadClientStatusRepository>()
|
||||||
|
.Setup(s => s.All())
|
||||||
|
.Returns(downloadClientStatuses);
|
||||||
|
|
||||||
|
Subject.Clean();
|
||||||
|
|
||||||
|
Mocker.GetMock<IDownloadClientStatusRepository>()
|
||||||
|
.Verify(v => v.UpdateMany(
|
||||||
|
It.Is<List<DownloadClientStatus>>(i => i.All(
|
||||||
|
s => s.InitialFailure.Value <= DateTime.UtcNow))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_set_most_recent_failure_when_its_in_the_future()
|
||||||
|
{
|
||||||
|
var downloadClientStatuses = Builder<DownloadClientStatus>.CreateListOfSize(5)
|
||||||
|
.All()
|
||||||
|
.With(t => t.DisabledTill = DateTime.UtcNow.AddDays(-5))
|
||||||
|
.With(t => t.InitialFailure = DateTime.UtcNow.AddDays(-5))
|
||||||
|
.With(t => t.MostRecentFailure = DateTime.UtcNow.AddDays(5))
|
||||||
|
.With(t => t.EscalationLevel = 1)
|
||||||
|
.BuildListOfNew();
|
||||||
|
|
||||||
|
Mocker.GetMock<IDownloadClientStatusRepository>()
|
||||||
|
.Setup(s => s.All())
|
||||||
|
.Returns(downloadClientStatuses);
|
||||||
|
|
||||||
|
Subject.Clean();
|
||||||
|
|
||||||
|
Mocker.GetMock<IDownloadClientStatusRepository>()
|
||||||
|
.Verify(v => v.UpdateMany(
|
||||||
|
It.Is<List<DownloadClientStatus>>(i => i.All(
|
||||||
|
s => s.MostRecentFailure.Value <= DateTime.UtcNow))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_not_change_statuses_when_times_are_in_the_past()
|
||||||
|
{
|
||||||
|
var downloadClientStatuses = Builder<DownloadClientStatus>.CreateListOfSize(5)
|
||||||
|
.All()
|
||||||
|
.With(t => t.DisabledTill = DateTime.UtcNow.AddDays(-5))
|
||||||
|
.With(t => t.InitialFailure = DateTime.UtcNow.AddDays(-5))
|
||||||
|
.With(t => t.MostRecentFailure = DateTime.UtcNow.AddDays(-5))
|
||||||
|
.With(t => t.EscalationLevel = 0)
|
||||||
|
.BuildListOfNew();
|
||||||
|
|
||||||
|
Mocker.GetMock<IDownloadClientStatusRepository>()
|
||||||
|
.Setup(s => s.All())
|
||||||
|
.Returns(downloadClientStatuses);
|
||||||
|
|
||||||
|
Subject.Clean();
|
||||||
|
|
||||||
|
Mocker.GetMock<IDownloadClientStatusRepository>()
|
||||||
|
.Verify(v => v.UpdateMany(
|
||||||
|
It.Is<List<DownloadClientStatus>>(i => i.Count == 0)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue