test: Verify exceptional case for env var parsing

pull/201/head
Robert Dailey 2 years ago
parent aa523a0e14
commit 8e22a5d561

@ -4,8 +4,10 @@ using NUnit.Framework;
using Recyclarr.Cli.TestLibrary; using Recyclarr.Cli.TestLibrary;
using Recyclarr.Common; using Recyclarr.Common;
using Recyclarr.TrashLib.Config; using Recyclarr.TrashLib.Config;
using Recyclarr.TrashLib.Config.EnvironmentVariables;
using Recyclarr.TrashLib.Config.Parsing; using Recyclarr.TrashLib.Config.Parsing;
using Recyclarr.TrashLib.Services.Sonarr.Config; using Recyclarr.TrashLib.Services.Sonarr.Config;
using YamlDotNet.Core;
namespace Recyclarr.TrashLib.Tests.Config.Parsing; namespace Recyclarr.TrashLib.Tests.Config.Parsing;
@ -168,4 +170,22 @@ sonarr:
} }
}); });
} }
[Test]
public void Throw_when_no_env_var_and_no_default()
{
var sut = Resolve<ConfigurationLoader>();
const string testYml = @"
sonarr:
instance:
base_url: !env_var SONARR_URL
api_key: value
";
var act = () => sut.LoadFromStream(new StringReader(testYml));
act.Should().Throw<YamlException>()
.WithInnerException<EnvironmentVariableNotDefinedException>();
}
} }

Loading…
Cancel
Save