mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-20 21:54:25 -04:00
Updater will stop process by ID on mono
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Processes;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Update.UpdateEngine;
|
||||
|
||||
@@ -13,11 +13,28 @@ namespace NzbDrone.Update.Test
|
||||
[TestFixture]
|
||||
public class InstallUpdateServiceFixture : TestBase<InstallUpdateService>
|
||||
{
|
||||
private string _targetFolder = @"C:\NzbDrone\".AsOsAgnostic();
|
||||
private const int _processId = 12;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<IAppFolderInfo>()
|
||||
.Setup(c => c.TempFolder).Returns(@"C:\Temp\");
|
||||
.Setup(c => c.TempFolder).Returns(@"C:\Temp\");
|
||||
}
|
||||
|
||||
private void GivenTargetFolderExists()
|
||||
{
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.FolderExists(_targetFolder))
|
||||
.Returns(true);
|
||||
}
|
||||
|
||||
private void GivenProcessExists()
|
||||
{
|
||||
Mocker.GetMock<IProcessProvider>()
|
||||
.Setup(c => c.Exists(_processId))
|
||||
.Returns(true);
|
||||
}
|
||||
|
||||
[TestCase(null)]
|
||||
@@ -25,16 +42,14 @@ namespace NzbDrone.Update.Test
|
||||
[TestCase(" ")]
|
||||
public void update_should_throw_target_folder_is_blank(string target)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => Subject.Start(target))
|
||||
Assert.Throws<ArgumentException>(() => Subject.Start(target, _processId))
|
||||
.Message.Should().StartWith("Target folder can not be null or empty");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void update_should_throw_if_target_folder_doesnt_exist()
|
||||
{
|
||||
string targetFolder = "c:\\NzbDrone\\";
|
||||
|
||||
Assert.Throws<DirectoryNotFoundException>(() => Subject.Start(targetFolder))
|
||||
Assert.Throws<DirectoryNotFoundException>(() => Subject.Start(_targetFolder, _processId))
|
||||
.Message.Should().StartWith("Target folder doesn't exist");
|
||||
}
|
||||
|
||||
@@ -42,18 +57,34 @@ namespace NzbDrone.Update.Test
|
||||
public void update_should_throw_if_update_folder_doesnt_exist()
|
||||
{
|
||||
const string sandboxFolder = @"C:\Temp\NzbDrone_update\nzbdrone";
|
||||
const string targetFolder = "c:\\NzbDrone\\";
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.FolderExists(targetFolder))
|
||||
.Returns(true);
|
||||
GivenTargetFolderExists();
|
||||
GivenProcessExists();
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.FolderExists(sandboxFolder))
|
||||
.Returns(false);
|
||||
|
||||
Assert.Throws<DirectoryNotFoundException>(() => Subject.Start(targetFolder))
|
||||
Assert.Throws<DirectoryNotFoundException>(() => Subject.Start(_targetFolder, _processId))
|
||||
.Message.Should().StartWith("Update folder doesn't exist");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void update_should_throw_if_process_is_zero()
|
||||
{
|
||||
GivenTargetFolderExists();
|
||||
|
||||
Assert.Throws<ArgumentException>(() => Subject.Start(_targetFolder, 0))
|
||||
.Message.Should().StartWith("Invalid process ID");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void update_should_throw_if_process_id_doesnt_exist()
|
||||
{
|
||||
GivenTargetFolderExists();
|
||||
|
||||
Assert.Throws<ArgumentException>(() => Subject.Start(_targetFolder, _processId))
|
||||
.Message.Should().StartWith("Process with ID doesn't exist");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user