mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 15:32:31 +01:00
Run update tests on linux
This commit is contained in:
parent
57912ab86d
commit
d3621fca71
@ -1,8 +1,11 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using ICSharpCode.SharpZipLib.Core;
|
||||
using ICSharpCode.SharpZipLib.GZip;
|
||||
using ICSharpCode.SharpZipLib.Tar;
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
@ -24,6 +27,21 @@ namespace NzbDrone.Common
|
||||
{
|
||||
_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))
|
||||
{
|
||||
var zipFile = new ZipFile(fileStream);
|
||||
@ -64,8 +82,19 @@ namespace NzbDrone.Common
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_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)
|
||||
|
@ -21,17 +21,30 @@ namespace NzbDrone.Core.Test.UpdateTests
|
||||
{
|
||||
private string _sandboxFolder;
|
||||
|
||||
private readonly UpdatePackage _updatePackage = new 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")
|
||||
};
|
||||
private UpdatePackage _updatePackage;
|
||||
|
||||
[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<ICheckUpdateService>().Setup(c => c.AvailableUpdate()).Returns(_updatePackage);
|
||||
@ -42,7 +55,6 @@ namespace NzbDrone.Core.Test.UpdateTests
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_delete_sandbox_before_update_if_folder_exists()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user