mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-18 21:35:51 -04:00
fixed diskscan
removed all stored status fields from episode
This commit is contained in:
+31
-3
@@ -5,13 +5,14 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using System.Linq;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFileTests
|
||||
{
|
||||
public class GhostFileCleanupFixture : CoreTest<GhostFileCleanupService>
|
||||
public class MediaFileTableCleanupServiceFixture : CoreTest<MediaFileTableCleanupService>
|
||||
{
|
||||
|
||||
private void GiveEpisodeFiles(IEnumerable<EpisodeFile> episodeFiles)
|
||||
@@ -30,6 +31,10 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(e => e.FileExists(It.Is<String>(c => c != DeletedPath)))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Setup(c => c.GetEpisodesByFileId(It.IsAny<int>()))
|
||||
.Returns(new List<Episode> { new Episode() });
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -40,7 +45,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
||||
|
||||
GiveEpisodeFiles(episodeFiles);
|
||||
|
||||
Subject.RemoveNonExistingFiles(0);
|
||||
Subject.Execute(new CleanMediaFileDb(0));
|
||||
|
||||
Mocker.GetMock<IEpisodeService>().Verify(c => c.UpdateEpisode(It.IsAny<Episode>()), Times.Never());
|
||||
}
|
||||
@@ -55,10 +60,33 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
||||
|
||||
GiveEpisodeFiles(episodeFiles);
|
||||
|
||||
Subject.RemoveNonExistingFiles(0);
|
||||
Subject.Execute(new CleanMediaFileDb(0));
|
||||
|
||||
Mocker.GetMock<IMediaFileService>().Verify(c => c.Delete(It.Is<EpisodeFile>(e => e.Path == DeletedPath)), Times.Exactly(2));
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_delete_files_that_dont_belong_to_any_episodes()
|
||||
{
|
||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(10)
|
||||
.Random(10)
|
||||
.With(c => c.Path = "ExistingPath")
|
||||
.Build();
|
||||
|
||||
GiveEpisodeFiles(episodeFiles);
|
||||
GivenFilesAreNotAttachedToEpisode();
|
||||
|
||||
Subject.Execute(new CleanMediaFileDb(0));
|
||||
|
||||
Mocker.GetMock<IMediaFileService>().Verify(c => c.Delete(It.IsAny<EpisodeFile>()), Times.Exactly(10));
|
||||
}
|
||||
|
||||
private void GivenFilesAreNotAttachedToEpisode()
|
||||
{
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Setup(c => c.GetEpisodesByFileId(It.IsAny<int>()))
|
||||
.Returns(new List<Episode>());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user