Drone factory would throw exception on unknown series instead of proper error.

This commit is contained in:
Taloth Saldono 2014-11-16 19:48:27 +01:00
parent 374fe07aba
commit 5fed3670c8
3 changed files with 19 additions and 1 deletions

View File

@ -16,6 +16,7 @@ using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
using FluentAssertions;
namespace NzbDrone.Core.Test.MediaFiles namespace NzbDrone.Core.Test.MediaFiles
{ {
@ -195,6 +196,20 @@ namespace NzbDrone.Core.Test.MediaFiles
.Verify(v => v.GetSeries(It.Is<String>(s => s.StartsWith(prefix))), Times.Never()); .Verify(v => v.GetSeries(It.Is<String>(s => s.StartsWith(prefix))), Times.Never());
} }
[Test]
public void should_return_importresult_on_unknown_series()
{
var fileName = @"C:\folder\file.mkv".AsOsAgnostic();
var result = Subject.ProcessFile(new FileInfo(fileName));
result.Should().HaveCount(1);
result.First().ImportDecision.Should().NotBeNull();
result.First().ImportDecision.LocalEpisode.Should().NotBeNull();
result.First().ImportDecision.LocalEpisode.Path.Should().Be(fileName);
result.First().Result.Should().Be(ImportResultType.Rejected);
}
private void VerifyNoImport() private void VerifyNoImport()
{ {
Mocker.GetMock<IImportApprovedEpisodes>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null), Mocker.GetMock<IImportApprovedEpisodes>().Verify(c => c.Import(It.IsAny<List<ImportDecision>>(), true, null),

View File

@ -132,7 +132,7 @@ namespace NzbDrone.Core.MediaFiles
if (series == null) if (series == null)
{ {
_logger.Debug("Unknown Series for file: {0}", fileInfo.Name); _logger.Debug("Unknown Series for file: {0}", fileInfo.Name);
return new List<ImportResult>() { new ImportResult(null, String.Format("Unknown Series for file: {0}", fileInfo.Name)) }; return new List<ImportResult>() { new ImportResult(new ImportDecision(new LocalEpisode { Path = fileInfo.FullName }, "Unknown Series"), String.Format("Unknown Series for file: {0}", fileInfo.Name)) };
} }
if (_diskProvider.IsFileLocked(fileInfo.FullName)) if (_diskProvider.IsFileLocked(fileInfo.FullName))

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Common.EnsureThat;
namespace NzbDrone.Core.MediaFiles.EpisodeImport namespace NzbDrone.Core.MediaFiles.EpisodeImport
{ {
@ -27,6 +28,8 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
public ImportResult(ImportDecision importDecision, params String[] errors) public ImportResult(ImportDecision importDecision, params String[] errors)
{ {
Ensure.That(importDecision, () => importDecision).IsNotNull();
ImportDecision = importDecision; ImportDecision = importDecision;
Errors = errors.ToList(); Errors = errors.ToList();
} }