Your ROOT_URL in app.ini is https://git.cloudchain.link/ but you are visiting https://dash.bss.nz/open-source-mirrors/recyclarr/commit/b3ab16b75b504ff9203439bea08374ad08505d39 You should set ROOT_URL correctly, otherwise the web may not work correctly.

refactor(config): sonarr release profile type is required

recyclarr
Robert Dailey 4 years ago
parent 12ff259c09
commit b3ab16b75b

@ -0,0 +1,39 @@
using System;
using System.IO;
using System.IO.Abstractions;
using FluentAssertions;
using NSubstitute;
using NUnit.Framework;
using Trash.Config;
using Trash.Sonarr;
using YamlDotNet.Core;
using YamlDotNet.Serialization.ObjectFactories;
namespace Trash.Tests.Sonarr
{
[TestFixture]
[Parallelizable(ParallelScope.All)]
public class SonarrConfigurationTest
{
[Test]
public void Deserialize_ReleaseProfileTypeMissing_Throw()
{
const string yaml = @"
sonarr:
- base_url: a
api_key: b
release_profiles:
- strict_negative_scores: true
";
var loader = new ConfigurationLoader<SonarrConfiguration>(
Substitute.For<IConfigurationProvider<SonarrConfiguration>>(),
Substitute.For<IFileSystem>(),
new DefaultObjectFactory());
Action act = () => loader.LoadFromStream(new StringReader(yaml), "sonarr");
act.Should().Throw<YamlException>()
.WithMessage("*'type' is required for 'release_profiles' elements");
}
}
}

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Flurl;
using JetBrains.Annotations;
using Trash.Config;
@ -24,7 +25,13 @@ namespace Trash.Sonarr
[UsedImplicitly(ImplicitUseTargetFlags.WithMembers)]
public class ReleaseProfileConfig
{
public ReleaseProfileType Type { get; init; }
// -1 does not map to a valid enumerator. this is to force validation to fail if it is not set from YAML
// all of this craziness is to avoid making the enum type nullable which will make using the property
// frustrating.
[EnumDataType(typeof(ReleaseProfileType),
ErrorMessage = "'type' is required for 'release_profiles' elements")]
public ReleaseProfileType Type { get; init; } = (ReleaseProfileType) (-1);
public bool StrictNegativeScores { get; init; }
public SonarrProfileFilterConfig Filter { get; init; } = new();
public ICollection<string> Tags { get; init; } = new List<string>();

Loading…
Cancel
Save