From 8e22a5d561bce3be457061106aa4efa117972657 Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Sat, 14 Jan 2023 22:53:54 -0600 Subject: [PATCH] test: Verify exceptional case for env var parsing --- .../Parsing/ConfigurationLoaderEnvVarTest.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Recyclarr.TrashLib.Tests/Config/Parsing/ConfigurationLoaderEnvVarTest.cs b/src/Recyclarr.TrashLib.Tests/Config/Parsing/ConfigurationLoaderEnvVarTest.cs index 8c3a8858..4faf3468 100644 --- a/src/Recyclarr.TrashLib.Tests/Config/Parsing/ConfigurationLoaderEnvVarTest.cs +++ b/src/Recyclarr.TrashLib.Tests/Config/Parsing/ConfigurationLoaderEnvVarTest.cs @@ -4,8 +4,10 @@ using NUnit.Framework; using Recyclarr.Cli.TestLibrary; using Recyclarr.Common; using Recyclarr.TrashLib.Config; +using Recyclarr.TrashLib.Config.EnvironmentVariables; using Recyclarr.TrashLib.Config.Parsing; using Recyclarr.TrashLib.Services.Sonarr.Config; +using YamlDotNet.Core; 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(); + + const string testYml = @" +sonarr: + instance: + base_url: !env_var SONARR_URL + api_key: value +"; + + var act = () => sut.LoadFromStream(new StringReader(testYml)); + + act.Should().Throw() + .WithInnerException(); + } }