mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-25 22:36:59 -04:00
Fixed: Scheduled Tasks that last ran in the future will be re-run after application start up
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Microsoft.Practices.ObjectBuilder2;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Housekeeping.Housekeepers;
|
||||
using NzbDrone.Core.Jobs;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||||
{
|
||||
[TestFixture]
|
||||
public class FixFutureRunScheduledTasksFixture : DbTest<FixFutureRunScheduledTasks, ScheduledTask>
|
||||
{
|
||||
[Test]
|
||||
public void should_set_last_execution_time_to_now_when_its_in_the_future()
|
||||
{
|
||||
var tasks = Builder<ScheduledTask>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(t => t.LastExecution = DateTime.UtcNow.AddDays(5))
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(tasks);
|
||||
|
||||
Subject.Clean();
|
||||
|
||||
AllStoredModels.ForEach(t => t.LastExecution.Should().BeBefore(DateTime.UtcNow));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_change_last_execution_time_when_its_in_the_past()
|
||||
{
|
||||
var expectedTime = DateTime.UtcNow.AddHours(-1);
|
||||
|
||||
var tasks = Builder<ScheduledTask>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(t => t.LastExecution = expectedTime)
|
||||
.BuildListOfNew();
|
||||
|
||||
Db.InsertMany(tasks);
|
||||
|
||||
Subject.Clean();
|
||||
|
||||
AllStoredModels.ForEach(t => t.LastExecution.Should().Be(expectedTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,6 +133,7 @@
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedHistoryItemsFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedEpisodeFilesFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupAdditionalNamingSpecsFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\FixFutureRunScheduledTasksFixture.cs" />
|
||||
<Compile Include="IndexerSearchTests\SearchDefinitionFixture.cs" />
|
||||
<Compile Include="IndexerTests\BasicRssParserFixture.cs" />
|
||||
<Compile Include="IndexerTests\IndexerServiceFixture.cs" />
|
||||
|
||||
Reference in New Issue
Block a user