1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-09-11 12:02:35 +02:00

Fixed: Early cleanup of completed tasks

This commit is contained in:
Mark McDowall 2015-06-02 21:37:28 -07:00
parent 1fbbfb3317
commit a2d8413b2a
3 changed files with 57 additions and 1 deletions

View File

@ -0,0 +1,55 @@
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Download;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Messaging.Commands
{
[TestFixture]
public class CommandQueueManagerFixture : CoreTest<CommandQueueManager>
{
[SetUp]
public void Setup()
{
var id = 0;
var commands = new List<CommandModel>();
Mocker.GetMock<ICommandRepository>()
.Setup(s => s.Insert(It.IsAny<CommandModel>()))
.Returns<CommandModel>(c =>
{
c.Id = id + 1;
commands.Add(c);
id++;
return c;
});
Mocker.GetMock<ICommandRepository>()
.Setup(s => s.Get(It.IsAny<int>()))
.Returns<int>(c =>
{
return commands.SingleOrDefault(e => e.Id == c);
});
}
[Test]
public void should_not_remove_commands_for_five_minutes_after_they_end()
{
var command = Subject.Push<CheckForFinishedDownloadCommand>(new CheckForFinishedDownloadCommand());
Subject.Start(command);
Subject.Complete(command, "All done");
Subject.CleanCommands();
Subject.Get(command.Id).Should().NotBeNull();
Mocker.GetMock<ICommandRepository>()
.Verify(v => v.Get(It.IsAny<int>()), Times.Never());
}
}
}

View File

@ -251,6 +251,7 @@
<Compile Include="MediaFiles\EpisodeImport\Specifications\UpgradeSpecificationFixture.cs" />
<Compile Include="MediaFiles\ImportApprovedEpisodesFixture.cs" />
<Compile Include="MediaFiles\MediaFileRepositoryFixture.cs" />
<Compile Include="Messaging\Commands\CommandQueueManagerFixture.cs" />
<Compile Include="MetadataSource\SkyHook\SkyHookProxySearchFixture.cs" />
<Compile Include="MetadataSource\SearchSeriesComparerFixture.cs" />
<Compile Include="MetadataSource\SkyHook\SkyHookProxyFixture.cs" />

View File

@ -151,7 +151,7 @@ public void CleanCommands()
{
_logger.Trace("Cleaning up old commands");
var old = _commandCache.Values.Where(c => c.EndedAt < DateTime.UtcNow.AddMinutes(5));
var old = _commandCache.Values.Where(c => c.EndedAt < DateTime.UtcNow.AddMinutes(-5));
foreach (var command in old)
{