mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-18 21:35:51 -04:00
cleaned up app update
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.UpdateTests
|
||||
{
|
||||
class GetAvailableUpdateFixture : CoreTest<UpdateService>
|
||||
{
|
||||
private static readonly Version LatestTestVersion = new Version("0.6.0.3");
|
||||
private const string LATEST_TEST_URL = "http://update.nzbdrone.com/_test/NzbDrone.master.0.6.0.3.zip";
|
||||
private const string LATEST_TEST_FILE_NAME = "NzbDrone.master.0.6.0.3.zip";
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<IConfigService>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_test/");
|
||||
Mocker.Resolve<HttpProvider>();
|
||||
}
|
||||
|
||||
[TestCase("0.6.0.9")]
|
||||
[TestCase("0.7.0.1")]
|
||||
[TestCase("1.0.0.0")]
|
||||
public void should_return_null_if_latest_is_lower_than_current_version(string currentVersion)
|
||||
{
|
||||
var updatePackage = Subject.GetAvailableUpdate(new Version(currentVersion));
|
||||
|
||||
updatePackage.Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_null_if_latest_is_equal_to_current_version()
|
||||
{
|
||||
var updatePackage = Subject.GetAvailableUpdate(LatestTestVersion);
|
||||
|
||||
updatePackage.Should().BeNull();
|
||||
}
|
||||
|
||||
[TestCase("0.0.0.0")]
|
||||
[TestCase("0.0.0.1")]
|
||||
[TestCase("0.0.10.10")]
|
||||
public void should_return_update_if_latest_is_higher_than_current_version(string currentVersion)
|
||||
{
|
||||
var updatePackage = Subject.GetAvailableUpdate(new Version(currentVersion));
|
||||
|
||||
updatePackage.Should().NotBeNull();
|
||||
updatePackage.Version.Should().Be(LatestTestVersion);
|
||||
updatePackage.FileName.Should().BeEquivalentTo(LATEST_TEST_FILE_NAME);
|
||||
updatePackage.Url.Should().BeEquivalentTo(LATEST_TEST_URL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.UpdateTests
|
||||
{
|
||||
class GetUpdateLogFixture : CoreTest
|
||||
{
|
||||
String UpdateLogFolder;
|
||||
|
||||
|
||||
[SetUp]
|
||||
public void setup()
|
||||
{
|
||||
WithTempAsAppPath();
|
||||
|
||||
UpdateLogFolder = Mocker.GetMock<EnvironmentProvider>().Object.GetUpdateLogFolder();
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(c => c.GetFiles(UpdateLogFolder, SearchOption.TopDirectoryOnly))
|
||||
.Returns(new []
|
||||
{
|
||||
"C:\\nzbdrone\\update\\2011.09.20-19-08.txt",
|
||||
"C:\\nzbdrone\\update\\2011.10.20-20-08.txt",
|
||||
"C:\\nzbdrone\\update\\2011.12.20-21-08.txt"
|
||||
});
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(c => c.FolderExists(UpdateLogFolder))
|
||||
.Returns(true);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void get_logs_should_return_empty_list_if_directory_doesnt_exist()
|
||||
{
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(c => c.FolderExists(UpdateLogFolder))
|
||||
.Returns(false);
|
||||
|
||||
var logs = Mocker.Resolve<UpdateService>().UpdateLogFile();
|
||||
logs.Should().BeEmpty();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void get_logs_should_return_list_of_files_in_log_folder()
|
||||
{
|
||||
var logs = Mocker.Resolve<UpdateService>().UpdateLogFile();
|
||||
logs.Should().HaveCount(3);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user