mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-17 15:59:36 +02:00
Application will automatically restart on db error.
Added SyncProvider Tests
This commit is contained in:
parent
fcf51978f9
commit
8cade435d1
@ -93,6 +93,7 @@
|
||||
<Compile Include="AutoMoq\Unity\AutoMockingContainerExtension.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SyncProviderTest.cs" />
|
||||
<Compile Include="RootDirProviderTest.cs" />
|
||||
<Compile Include="RssProviderTest.cs" />
|
||||
<Compile Include="HistoryProviderTest.cs" />
|
||||
|
45
NzbDrone.Core.Test/SyncProviderTest.cs
Normal file
45
NzbDrone.Core.Test/SyncProviderTest.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using AutoMoq;
|
||||
using Gallio.Framework;
|
||||
using MbUnit.Framework;
|
||||
using MbUnit.Framework.ContractVerifiers;
|
||||
using Moq;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using SubSonic.Repository;
|
||||
|
||||
namespace NzbDrone.Core.Test
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SyncProviderTest
|
||||
{
|
||||
[Test]
|
||||
public void None_existing_folder_returns_empty_list()
|
||||
{
|
||||
string path = "d:\\bad folder";
|
||||
|
||||
var mocker = new AutoMoqer();
|
||||
mocker.GetMock<DiskProvider>(MockBehavior.Strict)
|
||||
.Setup(m => m.FolderExists(path)).Returns(false);
|
||||
|
||||
var result = mocker.Resolve<SyncProvider>().GetUnmappedFolders(path);
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsEmpty(result);
|
||||
|
||||
mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void empty_folder_path_throws()
|
||||
{
|
||||
var mocker = new AutoMoqer();
|
||||
mocker.Resolve<SyncProvider>().GetUnmappedFolders("");
|
||||
}
|
||||
}
|
||||
}
|
@ -30,6 +30,11 @@ public MediaFileProvider(IRepository repository, ConfigProvider configProvider,
|
||||
_episodeProvider = episodeProvider;
|
||||
}
|
||||
|
||||
public MediaFileProvider()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scans the specified series folder for media files
|
||||
/// </summary>
|
||||
|
@ -41,15 +41,17 @@ public List<String> GetUnmappedFolders(string path)
|
||||
{
|
||||
Logger.Debug("Generating list of unmapped folders");
|
||||
if (String.IsNullOrEmpty(path))
|
||||
throw new InvalidOperationException("Invalid path provided");
|
||||
throw new ArgumentException("Invalid path provided", "path");
|
||||
|
||||
var results = new List<String>();
|
||||
|
||||
if (!_diskProvider.FolderExists(path))
|
||||
{
|
||||
Logger.Debug("Path supplied does not exist: {0}", path);
|
||||
return null;
|
||||
return results;
|
||||
}
|
||||
|
||||
var results = new List<String>();
|
||||
|
||||
foreach (string seriesFolder in _diskProvider.GetDirectories(path))
|
||||
{
|
||||
var cleanPath = Parser.NormalizePath(new DirectoryInfo(seriesFolder).FullName);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Data.SQLite;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
@ -74,11 +75,17 @@ protected void Application_Error(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect(Request.ApplicationPath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
Logger.FatalException(lastError.Message, lastError);
|
||||
|
||||
if (lastError is SQLiteException)
|
||||
{
|
||||
Logger.FatalException(lastError.Message, lastError);
|
||||
Logger.Warn("Restarting application");
|
||||
HttpRuntime.UnloadAppDomain();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void Application_BeginRequest()
|
||||
|
Loading…
Reference in New Issue
Block a user