You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.8 KiB
72 lines
1.8 KiB
2 years ago
|
using System.IO.Abstractions;
|
||
|
using Recyclarr.Common.Extensions;
|
||
1 year ago
|
using Recyclarr.Config.Parsing;
|
||
2 years ago
|
|
||
1 year ago
|
namespace Recyclarr.IntegrationTests;
|
||
2 years ago
|
|
||
|
[TestFixture]
|
||
1 year ago
|
public class ConfigSaverTest : IntegrationTestFixture
|
||
2 years ago
|
{
|
||
|
[Test]
|
||
|
public void Replace_file_when_already_exists()
|
||
|
{
|
||
|
var sut = Resolve<ConfigSaver>();
|
||
|
var config = new RootConfigYaml
|
||
|
{
|
||
|
Radarr = new Dictionary<string, RadarrConfigYaml>
|
||
|
{
|
||
|
{
|
||
|
"instance1", new RadarrConfigYaml
|
||
|
{
|
||
|
ApiKey = "apikey"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var destFile = Fs.CurrentDirectory().File("config.yml");
|
||
|
Fs.AddEmptyFile(destFile);
|
||
|
|
||
|
sut.Save(config, destFile);
|
||
|
|
||
|
Fs.GetFile(destFile).TextContents.Should().Contain("apikey");
|
||
|
}
|
||
|
|
||
|
[Test]
|
||
|
public void Create_intermediate_directories()
|
||
|
{
|
||
|
var sut = Resolve<ConfigSaver>();
|
||
|
|
||
|
var config = new RootConfigYaml
|
||
|
{
|
||
|
Radarr = new Dictionary<string, RadarrConfigYaml>
|
||
|
{
|
||
|
{
|
||
|
"instance1", new RadarrConfigYaml
|
||
|
{
|
||
|
ApiKey = "apikey",
|
||
|
BaseUrl = "http://baseurl.com"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var destFile = Fs.CurrentDirectory().SubDir("one", "two", "three").File("config.yml");
|
||
|
|
||
|
sut.Save(config, destFile);
|
||
|
|
||
1 year ago
|
const string expectedYaml =
|
||
1 year ago
|
"""
|
||
|
radarr:
|
||
|
instance1:
|
||
|
api_key: apikey
|
||
|
base_url: http://baseurl.com
|
||
1 year ago
|
|
||
1 year ago
|
""";
|
||
2 years ago
|
|
||
|
var expectedFile = Fs.GetFile(destFile);
|
||
|
expectedFile.Should().NotBeNull();
|
||
|
expectedFile.TextContents.Should().Be(expectedYaml);
|
||
|
}
|
||
|
}
|