1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-10 11:10:40 +02:00

Fixed update client path issue

This commit is contained in:
kay.one 2011-11-13 19:09:34 -08:00
parent 6369d4f817
commit fbf7d20c5d
6 changed files with 17 additions and 15 deletions

View File

@ -92,7 +92,7 @@
<Compile Include="JobTests\SearchJobTest.cs" />
<Compile Include="ProviderTests\PostDownloadProviderTests\ProcessDownloadFixture.cs" />
<Compile Include="ProviderTests\JobProviderTests\TestJobs.cs" />
<Compile Include="ProviderTests\UpdateProviderTests\PreformUpdateFixture.cs" />
<Compile Include="ProviderTests\UpdateProviderTests\StartUpdateFixture.cs" />
<Compile Include="ProviderTests\UpdateProviderTests\GetAvilableUpdateFixture.cs" />
<Compile Include="SortHelperTest.cs" />
<Compile Include="ProviderTests\EpisodeProviderTest_DeleteInvalidEpisodes.cs" />

View File

@ -14,7 +14,7 @@
namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
{
[TestFixture]
internal class PreformUpdateFixture : CoreTest
internal class StartUpdateFixture : CoreTest
{
private const string SANDBOX_FOLDER = @"C:\Temp\nzbdrone_update\";
@ -41,7 +41,7 @@ public void should_delete_sandbox_before_update_if_folder_exists()
Mocker.GetMock<DiskProvider>().Setup(c => c.FolderExists(SANDBOX_FOLDER)).Returns(true);
//Act
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
Mocker.Resolve<UpdateProvider>().StartUpdate(updatePackage);
//Assert
Mocker.GetMock<DiskProvider>().Verify(c => c.DeleteFolder(SANDBOX_FOLDER, true));
@ -53,7 +53,7 @@ public void should_not_delete_sandbox_before_update_if_folder_doesnt_exists()
Mocker.GetMock<DiskProvider>().Setup(c => c.FolderExists(SANDBOX_FOLDER)).Returns(false);
//Act
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
Mocker.Resolve<UpdateProvider>().StartUpdate(updatePackage);
//Assert
Mocker.GetMock<DiskProvider>().Verify(c => c.DeleteFolder(SANDBOX_FOLDER, true), Times.Never());
@ -65,7 +65,7 @@ public void Should_download_update_package()
var updateArchive = Path.Combine(SANDBOX_FOLDER, updatePackage.FileName);
//Act
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
Mocker.Resolve<UpdateProvider>().StartUpdate(updatePackage);
//Assert
Mocker.GetMock<HttpProvider>().Verify(
@ -78,7 +78,7 @@ public void Should_extract_update_package()
var updateArchive = Path.Combine(SANDBOX_FOLDER, updatePackage.FileName);
//Act
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
Mocker.Resolve<UpdateProvider>().StartUpdate(updatePackage);
//Assert
Mocker.GetMock<ArchiveProvider>().Verify(
@ -91,7 +91,7 @@ public void Should_copy_update_client_to_root_of_sandbox()
var updateClientFolder = Mocker.GetMock<EnviromentProvider>().Object.GetUpdateClientFolder();
//Act
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
Mocker.Resolve<UpdateProvider>().StartUpdate(updatePackage);
//Assert
Mocker.GetMock<DiskProvider>().Verify(
@ -108,13 +108,13 @@ public void should_start_update_client()
.SetupGet(c => c.NzbDroneProcessIdFromEnviroment).Returns(12);
//Act
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
Mocker.Resolve<UpdateProvider>().StartUpdate(updatePackage);
//Assert
Mocker.GetMock<ProcessProvider>().Verify(
c => c.Start(It.Is<ProcessStartInfo>(p =>
p.FileName == updateClientPath &&
p.Arguments == "/12 /" + _clientGuid.ToString())
p.Arguments == "12 " + _clientGuid.ToString())
));
}
@ -134,7 +134,7 @@ public void Should_download_and_extract_to_temp_folder()
Mocker.Resolve<HttpProvider>();
Mocker.Resolve<DiskProvider>();
Mocker.Resolve<ArchiveProvider>();
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
Mocker.Resolve<UpdateProvider>().StartUpdate(updatePackage);
updateSubFolder.Refresh();
//Assert

View File

@ -27,7 +27,7 @@ public virtual void Start(ProgressNotification notification, int targetId, int s
var updatePackage = _updateProvider.GetAvilableUpdate();
_updateProvider.StartUpgrade(updatePackage);
_updateProvider.StartUpdate(updatePackage);
}
}
}

View File

@ -78,7 +78,7 @@ public virtual UpdatePackage GetAvilableUpdate()
return null;
}
public virtual void StartUpgrade(UpdatePackage updatePackage)
public virtual void StartUpdate(UpdatePackage updatePackage)
{
var packageDestination = Path.Combine(_enviromentProvider.GetUpdateSandboxFolder(), updatePackage.FileName);
@ -104,7 +104,7 @@ public virtual void StartUpgrade(UpdatePackage updatePackage)
var startInfo = new ProcessStartInfo()
{
FileName = _enviromentProvider.GetUpdateClientExePath(),
Arguments = string.Format("/{0} /{1}", _enviromentProvider.NzbDroneProcessIdFromEnviroment, _configFileProvider.Guid)
Arguments = string.Format("{0} {1}", _enviromentProvider.NzbDroneProcessIdFromEnviroment, _configFileProvider.Guid)
};
_processProvider.Start(startInfo);

View File

@ -64,7 +64,7 @@ public void should_call_update_with_corret_path()
_program.Start(new[] { "12", "" });
//Assert
Mocker.GetMock<UpdateProvider>().Verify(c => c.Start(ProcessPath), Times.Once());
Mocker.GetMock<UpdateProvider>().Verify(c => c.Start(@"C:\NzbDrone"), Times.Once());
}

View File

@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Linq;
using NLog;
using NzbDrone.Common;
@ -52,7 +53,8 @@ public void Start(string[] args)
VerfityArguments(args);
int processId = ParseProcessId(args);
string appPath = _processProvider.GetProcessById(processId).StartPath;
FileInfo exeFileInfo = new FileInfo(_processProvider.GetProcessById(processId).StartPath);
string appPath = exeFileInfo.Directory.FullName;
logger.Info("Starting update process");
_updateProvider.Start(appPath);