Fixed: Lidarr Lists use correct metadata server (#800)
parent
35c19dac5f
commit
add32ff9f3
@ -0,0 +1,51 @@
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MetadataSource;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Common.Cloud;
|
||||
using NzbDrone.Common.Http;
|
||||
|
||||
namespace NzbDrone.Core.Test.MetadataSource
|
||||
{
|
||||
[TestFixture]
|
||||
public class MetadataRequestBuilderFixture : CoreTest<MetadataRequestBuilder>
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.Setup(s => s.MetadataSource)
|
||||
.Returns("");
|
||||
|
||||
Mocker.GetMock<ILidarrCloudRequestBuilder>()
|
||||
.Setup(s => s.Search)
|
||||
.Returns(new HttpRequestBuilder("https://api.lidarr.audio/api/v0.4/{route}").CreateFactory());
|
||||
}
|
||||
|
||||
private void WithCustomProvider()
|
||||
{
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.Setup(s => s.MetadataSource)
|
||||
.Returns("http://api.lidarr.audio/api/testing/");
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void should_use_user_definied_if_not_blank()
|
||||
{
|
||||
WithCustomProvider();
|
||||
|
||||
var details = Subject.GetRequestBuilder().Create();
|
||||
|
||||
details.BaseUrl.ToString().Should().Contain("testing");
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void should_use_default_if_config_blank()
|
||||
{
|
||||
var details = Subject.GetRequestBuilder().Create();
|
||||
|
||||
details.BaseUrl.ToString().Should().Contain("v0.4");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
using NzbDrone.Common.Cloud;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.Core.MetadataSource
|
||||
{
|
||||
|
||||
public interface IMetadataRequestBuilder
|
||||
{
|
||||
IHttpRequestBuilderFactory GetRequestBuilder();
|
||||
}
|
||||
public class MetadataRequestBuilder : IMetadataRequestBuilder
|
||||
{
|
||||
private readonly IConfigService _configService;
|
||||
|
||||
private readonly ILidarrCloudRequestBuilder _defaultRequestFactory;
|
||||
|
||||
public MetadataRequestBuilder(IConfigService configService, ILidarrCloudRequestBuilder defaultRequestBuilder)
|
||||
{
|
||||
_configService = configService;
|
||||
_defaultRequestFactory = defaultRequestBuilder;
|
||||
}
|
||||
|
||||
public IHttpRequestBuilderFactory GetRequestBuilder()
|
||||
{
|
||||
if (_configService.MetadataSource.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
return new HttpRequestBuilder(_configService.MetadataSource.TrimEnd("/") + "/{route}").CreateFactory();
|
||||
}
|
||||
else
|
||||
{
|
||||
return _defaultRequestFactory.Search;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue