From 7050a20df50b963aefee613e795783bd80eee1c7 Mon Sep 17 00:00:00 2001 From: ta264 Date: Sun, 15 Sep 2019 21:07:01 +0100 Subject: [PATCH] Fixed: Integration tests on Mono 5.12 and 5.14 Mono 5.12 and 5.14 has a bug that means RestSharp can't handle non-200 responses. Fix status api call so tests start and disable the tests that use non-200 responses on these mono versions --- .../ApiTests/ArtistFixture.cs | 6 ++++++ .../ApiTests/DownloadClientFixture.cs | 8 +++++++ .../ApiTests/NamingConfigFixture.cs | 10 +++++++++ .../ApiTests/RootFolderFixture.cs | 2 ++ .../GenericApiFixture.cs | 3 ++- .../HttpLogFixture.cs | 2 ++ .../IntegrationTestBase.cs | 21 ++++++++++++++----- src/NzbDrone.Test.Common/NzbDroneRunner.cs | 2 +- 8 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/NzbDrone.Integration.Test/ApiTests/ArtistFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/ArtistFixture.cs index df7b29013..91ce8402f 100644 --- a/src/NzbDrone.Integration.Test/ApiTests/ArtistFixture.cs +++ b/src/NzbDrone.Integration.Test/ApiTests/ArtistFixture.cs @@ -32,6 +32,8 @@ namespace NzbDrone.Integration.Test.ApiTests [Test, Order(0)] public void add_artist_without_profileid_should_return_badrequest() { + IgnoreOnMonoVersions("5.12", "5.14"); + EnsureNoArtist("f59c5520-5f46-4d2c-b2c4-822eabf53419", "Linkin Park"); var artist = Artist.Lookup("lidarr:f59c5520-5f46-4d2c-b2c4-822eabf53419").Single(); @@ -44,6 +46,8 @@ namespace NzbDrone.Integration.Test.ApiTests [Test, Order(0)] public void add_artist_without_path_should_return_badrequest() { + IgnoreOnMonoVersions("5.12", "5.14"); + EnsureNoArtist("f59c5520-5f46-4d2c-b2c4-822eabf53419", "Linkin Park"); var artist = Artist.Lookup("lidarr:f59c5520-5f46-4d2c-b2c4-822eabf53419").Single(); @@ -100,6 +104,8 @@ namespace NzbDrone.Integration.Test.ApiTests [Test] public void get_artist_by_unknown_id_should_return_404() { + IgnoreOnMonoVersions("5.12", "5.14"); + var result = Artist.InvalidGet(1000000); } diff --git a/src/NzbDrone.Integration.Test/ApiTests/DownloadClientFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/DownloadClientFixture.cs index 302eb780a..d346c7991 100644 --- a/src/NzbDrone.Integration.Test/ApiTests/DownloadClientFixture.cs +++ b/src/NzbDrone.Integration.Test/ApiTests/DownloadClientFixture.cs @@ -11,6 +11,8 @@ namespace NzbDrone.Integration.Test.ApiTests [Test, Order(0)] public void add_downloadclient_without_name_should_return_badrequest() { + IgnoreOnMonoVersions("5.12", "5.14"); + EnsureNoDownloadClient(); var schema = DownloadClients.Schema().First(v => v.Implementation == "UsenetBlackhole"); @@ -25,6 +27,8 @@ namespace NzbDrone.Integration.Test.ApiTests [Test, Order(0)] public void add_downloadclient_without_nzbfolder_should_return_badrequest() { + IgnoreOnMonoVersions("5.12", "5.14"); + EnsureNoDownloadClient(); var schema = DownloadClients.Schema().First(v => v.Implementation == "UsenetBlackhole"); @@ -39,6 +43,8 @@ namespace NzbDrone.Integration.Test.ApiTests [Test, Order(0)] public void add_downloadclient_without_watchfolder_should_return_badrequest() { + IgnoreOnMonoVersions("5.12", "5.14"); + EnsureNoDownloadClient(); var schema = DownloadClients.Schema().First(v => v.Implementation == "UsenetBlackhole"); @@ -90,6 +96,8 @@ namespace NzbDrone.Integration.Test.ApiTests [Test] public void get_downloadclient_by_unknown_id_should_return_404() { + IgnoreOnMonoVersions("5.12", "5.14"); + var result = DownloadClients.InvalidGet(1000000); } diff --git a/src/NzbDrone.Integration.Test/ApiTests/NamingConfigFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/NamingConfigFixture.cs index 3de293f9a..12b566645 100644 --- a/src/NzbDrone.Integration.Test/ApiTests/NamingConfigFixture.cs +++ b/src/NzbDrone.Integration.Test/ApiTests/NamingConfigFixture.cs @@ -36,6 +36,8 @@ namespace NzbDrone.Integration.Test.ApiTests [Test] public void should_get_bad_request_if_standard_format_is_empty() { + IgnoreOnMonoVersions("5.12", "5.14"); + var config = NamingConfig.GetSingle(); config.RenameTracks = true; config.StandardTrackFormat = ""; @@ -48,6 +50,8 @@ namespace NzbDrone.Integration.Test.ApiTests [Test] public void should_get_bad_request_if_standard_format_doesnt_contain_track_number_and_title() { + IgnoreOnMonoVersions("5.12", "5.14"); + var config = NamingConfig.GetSingle(); config.RenameTracks = true; config.StandardTrackFormat = "{track:00}"; @@ -59,6 +63,8 @@ namespace NzbDrone.Integration.Test.ApiTests [Test] public void should_not_require_format_when_rename_tracks_is_false() { + IgnoreOnMonoVersions("5.12", "5.14"); + var config = NamingConfig.GetSingle(); config.RenameTracks = false; config.StandardTrackFormat = ""; @@ -70,6 +76,8 @@ namespace NzbDrone.Integration.Test.ApiTests [Test] public void should_require_format_when_rename_tracks_is_true() { + IgnoreOnMonoVersions("5.12", "5.14"); + var config = NamingConfig.GetSingle(); config.RenameTracks = true; config.StandardTrackFormat = ""; @@ -81,6 +89,8 @@ namespace NzbDrone.Integration.Test.ApiTests [Test] public void should_get_bad_request_if_artist_folder_format_does_not_contain_artist_name() { + IgnoreOnMonoVersions("5.12", "5.14"); + var config = NamingConfig.GetSingle(); config.RenameTracks = true; config.ArtistFolderFormat = "This and That"; diff --git a/src/NzbDrone.Integration.Test/ApiTests/RootFolderFixture.cs b/src/NzbDrone.Integration.Test/ApiTests/RootFolderFixture.cs index 5bae86b11..e22e3c821 100644 --- a/src/NzbDrone.Integration.Test/ApiTests/RootFolderFixture.cs +++ b/src/NzbDrone.Integration.Test/ApiTests/RootFolderFixture.cs @@ -44,6 +44,8 @@ namespace NzbDrone.Integration.Test.ApiTests [Test] public void invalid_path_should_return_bad_request() { + IgnoreOnMonoVersions("5.12", "5.14"); + var rootFolder = new RootFolderResource { Path = "invalid_path" diff --git a/src/NzbDrone.Integration.Test/GenericApiFixture.cs b/src/NzbDrone.Integration.Test/GenericApiFixture.cs index d4295a459..2f2b2bca7 100644 --- a/src/NzbDrone.Integration.Test/GenericApiFixture.cs +++ b/src/NzbDrone.Integration.Test/GenericApiFixture.cs @@ -36,6 +36,7 @@ namespace NzbDrone.Integration.Test [TestCase("application/junk")] public void should_get_unacceptable_with_accept_header(string header) { + IgnoreOnMonoVersions("5.12", "5.14"); var request = new RestRequest("system/status") { @@ -48,4 +49,4 @@ namespace NzbDrone.Integration.Test response.StatusCode.Should().Be(HttpStatusCode.NotAcceptable); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Integration.Test/HttpLogFixture.cs b/src/NzbDrone.Integration.Test/HttpLogFixture.cs index 15e9fa949..6ced140dc 100644 --- a/src/NzbDrone.Integration.Test/HttpLogFixture.cs +++ b/src/NzbDrone.Integration.Test/HttpLogFixture.cs @@ -11,6 +11,8 @@ namespace NzbDrone.Integration.Test [Test] public void should_log_on_error() { + IgnoreOnMonoVersions("5.12", "5.14"); + var config = HostConfig.Get(1); config.LogLevel = "Trace"; HostConfig.Put(config); diff --git a/src/NzbDrone.Integration.Test/IntegrationTestBase.cs b/src/NzbDrone.Integration.Test/IntegrationTestBase.cs index 8d10c2b70..4348a40f7 100644 --- a/src/NzbDrone.Integration.Test/IntegrationTestBase.cs +++ b/src/NzbDrone.Integration.Test/IntegrationTestBase.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Threading; @@ -12,21 +11,17 @@ using NLog.Config; using NLog.Targets; using NUnit.Framework; using Lidarr.Api.V1.Blacklist; -using Lidarr.Api.V1.Commands; using Lidarr.Api.V1.Config; using Lidarr.Api.V1.DownloadClient; -using Lidarr.Api.V1.TrackFiles; using Lidarr.Api.V1.History; using Lidarr.Api.V1.Profiles.Quality; using Lidarr.Api.V1.RootFolders; using Lidarr.Api.V1.Artist; using Lidarr.Api.V1.Albums; -using Lidarr.Api.V1.Tracks; using Lidarr.Api.V1.Tags; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Serializer; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Music.Commands; using NzbDrone.Integration.Test.Client; using NzbDrone.SignalR; using NzbDrone.Test.Common.Categories; @@ -171,6 +166,22 @@ namespace NzbDrone.Integration.Test } } + protected void IgnoreOnMonoVersions(params string[] version_strings) + { + if (!PlatformInfo.IsMono) + { + return; + } + + var current = PlatformInfo.GetVersion(); + var versions = version_strings.Select(x => new Version(x)).ToList(); + + if (versions.Any(x => x.Major == current.Major && x.Minor == current.Minor)) + { + throw new IgnoreException($"Ignored on mono {PlatformInfo.GetVersion()}"); + } + } + public string GetTempDirectory(params string[] args) { var path = Path.Combine(TempDirectory, Path.Combine(args)); diff --git a/src/NzbDrone.Test.Common/NzbDroneRunner.cs b/src/NzbDrone.Test.Common/NzbDroneRunner.cs index d21136637..284e45dba 100644 --- a/src/NzbDrone.Test.Common/NzbDroneRunner.cs +++ b/src/NzbDrone.Test.Common/NzbDroneRunner.cs @@ -24,7 +24,7 @@ namespace NzbDrone.Test.Common public NzbDroneRunner(Logger logger, int port = 8686) { _processProvider = new ProcessProvider(logger); - _restClient = new RestClient("http://localhost:8686/api"); + _restClient = new RestClient("http://localhost:8686/api/v1"); } public void Start()