mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-27 02:07:41 +00:00
Fixed bug when a file that wasn't parsable would try to be imported
This commit is contained in:
parent
90c6b78e8c
commit
69406a95d4
2 changed files with 37 additions and 1 deletions
|
@ -166,6 +166,40 @@ namespace NzbDrone.Core.Test
|
||||||
Assert.IsNull(result);
|
Assert.IsNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[Description("Verifies that a un-parsable file isn't imported")]
|
||||||
|
public void import_unparsable_file()
|
||||||
|
{
|
||||||
|
//Arrange
|
||||||
|
/////////////////////////////////////////
|
||||||
|
|
||||||
|
//Constants
|
||||||
|
const string fileName = @"WEEDS.avi";
|
||||||
|
const int size = 12345;
|
||||||
|
|
||||||
|
//Fakes
|
||||||
|
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||||
|
|
||||||
|
//Mocks
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
|
||||||
|
mocker.GetMock<IRepository>(MockBehavior.Strict)
|
||||||
|
.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
|
||||||
|
|
||||||
|
mocker.GetMock<DiskProvider>()
|
||||||
|
.Setup(e => e.GetSize(fileName)).Returns(size).Verifiable();
|
||||||
|
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = mocker.Resolve<MediaFileProvider>().ImportFile(fakeSeries, fileName);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
Assert.IsNull(result);
|
||||||
|
ExceptionVerification.ExcpectedWarns(1);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[Description("Verifies that a new file imported properly")]
|
[Description("Verifies that a new file imported properly")]
|
||||||
public void import_sample_file()
|
public void import_sample_file()
|
||||||
|
|
|
@ -72,11 +72,13 @@ namespace NzbDrone.Core.Providers
|
||||||
if (!_repository.Exists<EpisodeFile>(e => e.Path == Parser.NormalizePath(filePath)))
|
if (!_repository.Exists<EpisodeFile>(e => e.Path == Parser.NormalizePath(filePath)))
|
||||||
{
|
{
|
||||||
var parseResult = Parser.ParseEpisodeInfo(filePath);
|
var parseResult = Parser.ParseEpisodeInfo(filePath);
|
||||||
parseResult.CleanTitle = series.Title;//replaces the nasty path as title to help with logging
|
|
||||||
|
|
||||||
if (parseResult == null)
|
if (parseResult == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
parseResult.CleanTitle = series.Title;//replaces the nasty path as title to help with logging
|
||||||
|
|
||||||
//Stores the list of episodes to add to the EpisodeFile
|
//Stores the list of episodes to add to the EpisodeFile
|
||||||
var episodes = new List<Episode>();
|
var episodes = new List<Episode>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue