mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-07 13:32:17 -07:00
Fixed: Error messages when config file is empty or contains invalid characters
Closes #1104
This commit is contained in:
parent
4f5d79b189
commit
ea0982ecae
3 changed files with 45 additions and 3 deletions
|
@ -17,17 +17,18 @@ namespace NzbDrone.Common.Test
|
|||
public class ConfigFileProviderTest : TestBase<ConfigFileProvider>
|
||||
{
|
||||
private string _configFileContents;
|
||||
private string _configFilePath;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
WithTempAsAppPath();
|
||||
|
||||
var configFile = Mocker.Resolve<IAppFolderInfo>().GetConfigPath();
|
||||
_configFilePath = Mocker.Resolve<IAppFolderInfo>().GetConfigPath();
|
||||
|
||||
_configFileContents = null;
|
||||
|
||||
WithMockConfigFile(configFile);
|
||||
WithMockConfigFile(_configFilePath);
|
||||
}
|
||||
|
||||
protected void WithMockConfigFile(string configFile)
|
||||
|
@ -187,5 +188,30 @@ namespace NzbDrone.Common.Test
|
|||
Subject.SslPort.Should().Be(sslPort);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_if_config_file_is_empty()
|
||||
{
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(v => v.FileExists(_configFilePath))
|
||||
.Returns(true);
|
||||
|
||||
Assert.Throws<InvalidConfigFileException>(() => Subject.GetValue("key", "value"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_if_config_file_contains_only_null_character()
|
||||
{
|
||||
_configFileContents = "\0";
|
||||
|
||||
Assert.Throws<InvalidConfigFileException>(() => Subject.GetValue("key", "value"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_if_config_file_contains_invalid_xml()
|
||||
{
|
||||
_configFileContents = "{ \"key\": \"value\" }";
|
||||
|
||||
Assert.Throws<InvalidConfigFileException>(() => Subject.GetValue("key", "value"));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue