mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
fixed apptype detection during update
This commit is contained in:
parent
2573558321
commit
99f269cd95
11 changed files with 300 additions and 187 deletions
|
@ -5,38 +5,21 @@ using NUnit.Framework;
|
|||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Update.Providers;
|
||||
using NzbDrone.Update.UpdateEngine;
|
||||
|
||||
namespace NzbDrone.Update.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class ProgramFixture : TestBase
|
||||
public class ProgramFixture : TestBase<Program>
|
||||
{
|
||||
private Program _program;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_program = Mocker.Resolve<Program>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_if_null_passed_in()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => _program.Start(null));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => Subject.Start(null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_if_less_than_two_arguments_arent_passed_in()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => _program.Start(new[] { "" }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_if_more_than_two_arguments_arent_passed_in()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => _program.Start(new[] { "", "", "" }));
|
||||
}
|
||||
|
||||
[TestCase("d", "")]
|
||||
[TestCase("", "")]
|
||||
|
@ -46,7 +29,7 @@ namespace NzbDrone.Update.Test
|
|||
[TestCase(".", "")]
|
||||
public void should_throw_if_first_arg_isnt_an_int(string arg1, string arg2)
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => _program.Start(new[] { arg1, arg2 }));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => Subject.Start(new[] { arg1, arg2 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -57,11 +40,11 @@ namespace NzbDrone.Update.Test
|
|||
Mocker.GetMock<IProcessProvider>().Setup(c => c.GetProcessById(12))
|
||||
.Returns(new ProcessInfo() { StartPath = ProcessPath });
|
||||
|
||||
|
||||
_program.Start(new[] { "12", "" });
|
||||
|
||||
|
||||
Mocker.GetMock<UpdateProvider>().Verify(c => c.Start(@"C:\NzbDrone"), Times.Once());
|
||||
Subject.Start(new[] { "12", "" });
|
||||
|
||||
|
||||
Mocker.GetMock<IInstallUpdateService>().Verify(c => c.Start(@"C:\NzbDrone"), Times.Once());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
/*
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
|
@ -7,7 +8,7 @@ using NUnit.Framework;
|
|||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Update.Providers;
|
||||
using NzbDrone.Update.UpdateEngine;
|
||||
|
||||
namespace NzbDrone.Update.Test
|
||||
{
|
||||
|
@ -58,7 +59,7 @@ namespace NzbDrone.Update.Test
|
|||
WithServiceRunning(true);
|
||||
|
||||
|
||||
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
|
||||
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
|
||||
|
||||
|
||||
Mocker.GetMock<IServiceProvider>().Verify(c => c.Stop(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
|
||||
|
@ -71,7 +72,7 @@ namespace NzbDrone.Update.Test
|
|||
WithServiceRunning(false);
|
||||
|
||||
|
||||
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
|
||||
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
|
||||
|
||||
|
||||
Mocker.GetMock<IServiceProvider>().Verify(c => c.Stop(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Never());
|
||||
|
@ -81,7 +82,7 @@ namespace NzbDrone.Update.Test
|
|||
public void should_not_stop_nzbdrone_service_if_service_isnt_installed()
|
||||
{
|
||||
|
||||
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
|
||||
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
|
||||
|
||||
|
||||
Mocker.GetMock<IServiceProvider>().Verify(c => c.Stop(It.IsAny<string>()), Times.Never());
|
||||
|
@ -97,7 +98,7 @@ namespace NzbDrone.Update.Test
|
|||
.Returns(proccesses);
|
||||
|
||||
|
||||
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
|
||||
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
|
||||
|
||||
|
||||
Mocker.GetMock<IProcessProvider>().Verify(c => c.KillAll(ProcessProvider.NzbDroneProcessName), Times.Once());
|
||||
|
@ -111,7 +112,7 @@ namespace NzbDrone.Update.Test
|
|||
.Returns(new List<ProcessInfo>());
|
||||
|
||||
|
||||
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
|
||||
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
|
||||
|
||||
|
||||
Mocker.GetMock<IProcessProvider>().Verify(c => c.Kill(It.IsAny<int>()), Times.Never());
|
||||
|
@ -123,7 +124,7 @@ namespace NzbDrone.Update.Test
|
|||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.CopyDirectory(TARGET_FOLDER, BACKUP_FOLDER));
|
||||
|
||||
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
|
||||
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -135,7 +136,7 @@ namespace NzbDrone.Update.Test
|
|||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.DeleteFolder(UPDATE_FOLDER, true));
|
||||
|
||||
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
|
||||
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -146,7 +147,7 @@ namespace NzbDrone.Update.Test
|
|||
.Throws(new IOException());
|
||||
|
||||
|
||||
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
|
||||
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
|
||||
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
@ -161,7 +162,7 @@ namespace NzbDrone.Update.Test
|
|||
WithServiceRunning(true);
|
||||
|
||||
|
||||
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
|
||||
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
|
||||
|
||||
|
||||
VerifyServiceRestart();
|
||||
|
@ -174,7 +175,7 @@ namespace NzbDrone.Update.Test
|
|||
WithServiceRunning(false);
|
||||
|
||||
|
||||
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
|
||||
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
|
||||
|
||||
|
||||
VerifyProcessRestart();
|
||||
|
@ -191,7 +192,7 @@ namespace NzbDrone.Update.Test
|
|||
.Throws(new IOException());
|
||||
|
||||
|
||||
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
|
||||
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
|
||||
|
||||
|
||||
VerifyServiceRestart();
|
||||
|
@ -209,7 +210,7 @@ namespace NzbDrone.Update.Test
|
|||
.Throws(new IOException());
|
||||
|
||||
|
||||
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
|
||||
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
|
||||
|
||||
|
||||
VerifyProcessRestart();
|
||||
|
@ -237,3 +238,4 @@ namespace NzbDrone.Update.Test
|
|||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@ using FluentAssertions;
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Update.Providers;
|
||||
using NzbDrone.Update.UpdateEngine;
|
||||
|
||||
namespace NzbDrone.Update.Test
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ namespace NzbDrone.Update.Test
|
|||
[TestCase(" ")]
|
||||
public void update_should_throw_target_folder_is_blank(string target)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => Mocker.Resolve<UpdateProvider>().Start(target))
|
||||
Assert.Throws<ArgumentException>(() => Mocker.Resolve<InstallUpdateService>().Start(target))
|
||||
.Message.Should().StartWith("Target folder can not be null or empty");
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace NzbDrone.Update.Test
|
|||
{
|
||||
string targetFolder = "c:\\NzbDrone\\";
|
||||
|
||||
Assert.Throws<DirectoryNotFoundException>(() => Mocker.Resolve<UpdateProvider>().Start(targetFolder))
|
||||
Assert.Throws<DirectoryNotFoundException>(() => Mocker.Resolve<InstallUpdateService>().Start(targetFolder))
|
||||
.Message.Should().StartWith("Target folder doesn't exist");
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace NzbDrone.Update.Test
|
|||
.Setup(c => c.FolderExists(sandboxFolder))
|
||||
.Returns(false);
|
||||
|
||||
Assert.Throws<DirectoryNotFoundException>(() => Mocker.Resolve<UpdateProvider>().Start(targetFolder))
|
||||
Assert.Throws<DirectoryNotFoundException>(() => Mocker.Resolve<InstallUpdateService>().Start(targetFolder))
|
||||
.Message.Should().StartWith("Update folder doesn't exist");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue