2013-09-11 06:33:47 +00:00
|
|
|
using System;
|
2014-10-31 16:34:17 +00:00
|
|
|
using System.Linq;
|
2013-04-15 01:41:39 +00:00
|
|
|
using FluentAssertions;
|
|
|
|
using NUnit.Framework;
|
2018-04-21 04:59:31 +00:00
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
2014-12-02 06:48:11 +00:00
|
|
|
using NzbDrone.Common.Extensions;
|
2013-04-15 01:41:39 +00:00
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Core.Update;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.UpdateTests
|
|
|
|
{
|
|
|
|
public class UpdatePackageProviderFixture : CoreTest<UpdatePackageProvider>
|
|
|
|
{
|
2018-04-21 04:59:31 +00:00
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
|
|
|
Mocker.GetMock<IPlatformInfo>().SetupGet(c => c.Version).Returns(new Version("9.9.9"));
|
|
|
|
}
|
|
|
|
|
2013-04-16 00:08:06 +00:00
|
|
|
[Test]
|
2013-09-11 06:33:47 +00:00
|
|
|
public void no_update_when_version_higher()
|
2013-04-16 00:08:06 +00:00
|
|
|
{
|
|
|
|
UseRealHttp();
|
2017-03-06 21:23:25 +00:00
|
|
|
Subject.GetLatestUpdate("develop", new Version(10, 0)).Should().BeNull();
|
2013-09-11 06:33:47 +00:00
|
|
|
}
|
2013-04-15 01:41:39 +00:00
|
|
|
|
2013-09-11 06:33:47 +00:00
|
|
|
[Test]
|
2019-12-22 22:08:53 +00:00
|
|
|
[Platform(Exclude = "NetCore")]
|
2013-09-11 06:33:47 +00:00
|
|
|
public void finds_update_when_version_lower()
|
|
|
|
{
|
|
|
|
UseRealHttp();
|
2017-03-06 21:23:25 +00:00
|
|
|
Subject.GetLatestUpdate("develop", new Version(0, 2)).Should().NotBeNull();
|
2013-04-16 00:08:06 +00:00
|
|
|
}
|
2014-09-11 23:49:41 +00:00
|
|
|
|
2014-10-28 23:48:37 +00:00
|
|
|
[Test]
|
2017-03-06 21:23:25 +00:00
|
|
|
[Ignore("TODO: Update API")]
|
2014-10-28 23:48:37 +00:00
|
|
|
public void should_get_master_if_branch_doesnt_exit()
|
|
|
|
{
|
|
|
|
UseRealHttp();
|
2017-03-06 21:23:25 +00:00
|
|
|
Subject.GetLatestUpdate("invalid_branch", new Version(0, 2)).Should().NotBeNull();
|
2014-10-28 23:48:37 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 23:49:41 +00:00
|
|
|
[Test]
|
|
|
|
public void should_get_recent_updates()
|
|
|
|
{
|
2020-11-22 04:53:48 +00:00
|
|
|
const string branch = "nightly";
|
2014-09-11 23:49:41 +00:00
|
|
|
UseRealHttp();
|
2021-01-25 04:33:54 +00:00
|
|
|
var recent = Subject.GetRecentUpdates(branch, new Version(2, 0), null);
|
2020-07-17 01:48:55 +00:00
|
|
|
var recentWithChanges = recent.Where(c => c.Changes != null);
|
2014-09-11 23:49:41 +00:00
|
|
|
|
|
|
|
recent.Should().NotBeEmpty();
|
|
|
|
recent.Should().OnlyContain(c => c.Hash.IsNotNullOrWhiteSpace());
|
2017-03-06 21:23:25 +00:00
|
|
|
recent.Should().OnlyContain(c => c.FileName.Contains("Radarr"));
|
2015-01-01 06:07:39 +00:00
|
|
|
recent.Should().OnlyContain(c => c.ReleaseDate.Year >= 2014);
|
2020-07-17 01:48:55 +00:00
|
|
|
|
|
|
|
if (recentWithChanges.Any())
|
|
|
|
{
|
|
|
|
recentWithChanges.Should().OnlyContain(c => c.Changes.New != null);
|
|
|
|
recentWithChanges.Should().OnlyContain(c => c.Changes.Fixed != null);
|
|
|
|
}
|
|
|
|
|
2014-10-28 23:48:37 +00:00
|
|
|
recent.Should().OnlyContain(c => c.Branch == branch);
|
2014-09-11 23:49:41 +00:00
|
|
|
}
|
2013-04-15 01:41:39 +00:00
|
|
|
}
|
|
|
|
}
|