mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 02:37:08 -07:00
Do not rename episodeFiles if the source and destination are the same (file is already named correctly).
This commit is contained in:
parent
2856c3dca3
commit
1c99541731
2 changed files with 58 additions and 2 deletions
|
@ -1,13 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
@ -163,5 +166,51 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
mocker.VerifyAllMocks();
|
||||
ExceptionVerification.ExcpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void move_should_not_move_file_if_source_and_destination_are_the_same_path()
|
||||
{
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(s => s.SeriesId = 5)
|
||||
.With(s => s.Title = "30 Rock")
|
||||
.Build();
|
||||
|
||||
var fakeEpisode = Builder<Episode>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.With(e => e.SeasonNumber = 1)
|
||||
.With(e => e.EpisodeNumber = 1)
|
||||
.Build();
|
||||
|
||||
const string filename = @"30 Rock - S01E01 - TBD";
|
||||
var fi = new FileInfo(Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".avi"));
|
||||
|
||||
var file = Builder<EpisodeFile>.CreateNew()
|
||||
.With(f => f.SeriesId = fakeSeries.SeriesId)
|
||||
.With(f => f.Path = fi.FullName)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(e => e.GetSeries(fakeSeries.SeriesId))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(e => e.GetEpisodesByFileId(file.EpisodeFileId))
|
||||
.Returns(fakeEpisode);
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries.Title, It.IsAny<QualityTypes>()))
|
||||
.Returns(filename);
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".avi"))
|
||||
.Returns(fi);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<DiskScanProvider>().MoveEpisodeFile(file, false);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue