mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-01-10 01:40:29 +01:00
Fixed: (GazelleGames) Serialization error on empty response
Fixes #1137
This commit is contained in:
parent
0a111e7572
commit
2e85a21576
3 changed files with 32 additions and 2 deletions
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"status": "success",
|
||||
"response": []
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.IndexerTests.GazelleGamesTests
|
||||
{
|
||||
|
|
@ -64,5 +65,19 @@ public async Task should_parse_recent_feed_from_GazelleGames()
|
|||
torrentInfo.DownloadVolumeFactor.Should().Be(1);
|
||||
torrentInfo.UploadVolumeFactor.Should().Be(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task should_not_error_if_empty_response()
|
||||
{
|
||||
var recentFeed = ReadAllText(@"Files/Indexers/GazelleGames/recentfeed-empty.json");
|
||||
|
||||
Mocker.GetMock<IIndexerHttpClient>()
|
||||
.Setup(o => o.ExecuteProxiedAsync(It.Is<HttpRequest>(v => v.Method == HttpMethod.Get), Subject.Definition))
|
||||
.Returns<HttpRequest, IndexerDefinition>((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader { { "Content-Type", "application/json" } }, new CookieCollection(), recentFeed)));
|
||||
|
||||
var releases = (await Subject.Fetch(new BasicSearchCriteria { Categories = new int[] { 2000 } })).Releases;
|
||||
|
||||
releases.Should().HaveCount(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -341,7 +341,18 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
return torrentInfos;
|
||||
}
|
||||
|
||||
foreach (var result in jsonResponse.Resource.Response)
|
||||
Dictionary<string, GazelleGamesGroup> response;
|
||||
|
||||
try
|
||||
{
|
||||
response = ((JObject)jsonResponse.Resource.Response).ToObject<Dictionary<string, GazelleGamesGroup>>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return torrentInfos;
|
||||
}
|
||||
|
||||
foreach (var result in response)
|
||||
{
|
||||
Dictionary<string, GazelleGamesTorrent> torrents;
|
||||
|
||||
|
|
@ -455,7 +466,7 @@ public override NzbDroneValidationResult Validate()
|
|||
public class GazelleGamesResponse
|
||||
{
|
||||
public string Status { get; set; }
|
||||
public Dictionary<string, GazelleGamesGroup> Response { get; set; }
|
||||
public object Response { get; set; }
|
||||
}
|
||||
|
||||
public class GazelleGamesGroup
|
||||
|
|
|
|||
Loading…
Reference in a new issue