mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Run update tests on linux
This commit is contained in:
parent
57912ab86d
commit
d3621fca71
@ -1,8 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using ICSharpCode.SharpZipLib.Core;
|
using ICSharpCode.SharpZipLib.Core;
|
||||||
|
using ICSharpCode.SharpZipLib.GZip;
|
||||||
|
using ICSharpCode.SharpZipLib.Tar;
|
||||||
using ICSharpCode.SharpZipLib.Zip;
|
using ICSharpCode.SharpZipLib.Zip;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
|
||||||
namespace NzbDrone.Common
|
namespace NzbDrone.Common
|
||||||
{
|
{
|
||||||
@ -24,6 +27,21 @@ public void Extract(string compressedFile, string destination)
|
|||||||
{
|
{
|
||||||
_logger.Trace("Extracting archive [{0}] to [{1}]", compressedFile, destination);
|
_logger.Trace("Extracting archive [{0}] to [{1}]", compressedFile, destination);
|
||||||
|
|
||||||
|
if (OsInfo.IsWindows)
|
||||||
|
{
|
||||||
|
ExtractZip(compressedFile, destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ExtractTgz(compressedFile, destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Trace("Extraction complete.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExtractZip(string compressedFile, string destination)
|
||||||
|
{
|
||||||
using (var fileStream = File.OpenRead(compressedFile))
|
using (var fileStream = File.OpenRead(compressedFile))
|
||||||
{
|
{
|
||||||
var zipFile = new ZipFile(fileStream);
|
var zipFile = new ZipFile(fileStream);
|
||||||
@ -64,8 +82,19 @@ public void Extract(string compressedFile, string destination)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_logger.Trace("Extraction complete.");
|
private void ExtractTgz(string compressedFile, string destination)
|
||||||
|
{
|
||||||
|
Stream inStream = File.OpenRead(compressedFile);
|
||||||
|
Stream gzipStream = new GZipInputStream(inStream);
|
||||||
|
|
||||||
|
TarArchive tarArchive = TarArchive.CreateInputTarArchive(gzipStream);
|
||||||
|
tarArchive.ExtractContents(destination);
|
||||||
|
tarArchive.Close();
|
||||||
|
|
||||||
|
gzipStream.Close();
|
||||||
|
inStream.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnZipError(TestStatus status, string message)
|
private void OnZipError(TestStatus status, string message)
|
||||||
|
@ -21,17 +21,30 @@ public class UpdateServiceFixture : CoreTest<InstallUpdateService>
|
|||||||
{
|
{
|
||||||
private string _sandboxFolder;
|
private string _sandboxFolder;
|
||||||
|
|
||||||
private readonly UpdatePackage _updatePackage = new UpdatePackage
|
private UpdatePackage _updatePackage;
|
||||||
{
|
|
||||||
FileName = "NzbDrone.develop.2.0.0.zip",
|
|
||||||
Url = "http://update.nzbdrone.com/v2/develop/windows/NzbDrone.develop.zip",
|
|
||||||
Version = new Version("2.0.0")
|
|
||||||
};
|
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
WindowsOnly();
|
if (OsInfo.IsLinux)
|
||||||
|
{
|
||||||
|
_updatePackage = new UpdatePackage
|
||||||
|
{
|
||||||
|
FileName = "NzbDrone.develop.2.0.0.0.tar.gz",
|
||||||
|
Url = "http://update.nzbdrone.com/v2/develop/mono/NzbDrone.develop.tar.gz",
|
||||||
|
Version = new Version("2.0.0.0")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_updatePackage = new UpdatePackage
|
||||||
|
{
|
||||||
|
FileName = "NzbDrone.develop.2.0.0.0.zip",
|
||||||
|
Url = "http://update.nzbdrone.com/v2/develop/windows/NzbDrone.develop.zip",
|
||||||
|
Version = new Version("2.0.0.0")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
Mocker.GetMock<IAppFolderInfo>().SetupGet(c => c.TempFolder).Returns(TempFolder);
|
Mocker.GetMock<IAppFolderInfo>().SetupGet(c => c.TempFolder).Returns(TempFolder);
|
||||||
Mocker.GetMock<ICheckUpdateService>().Setup(c => c.AvailableUpdate()).Returns(_updatePackage);
|
Mocker.GetMock<ICheckUpdateService>().Setup(c => c.AvailableUpdate()).Returns(_updatePackage);
|
||||||
@ -42,7 +55,6 @@ public void Setup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_delete_sandbox_before_update_if_folder_exists()
|
public void should_delete_sandbox_before_update_if_folder_exists()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user