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.
52 lines
1.8 KiB
52 lines
1.8 KiB
2 years ago
|
using System.IO.Abstractions;
|
||
1 year ago
|
using Recyclarr.Common;
|
||
|
using Recyclarr.Repo;
|
||
1 year ago
|
using Recyclarr.TestLibrary;
|
||
|
using Recyclarr.TestLibrary.AutoFixture;
|
||
1 year ago
|
using Recyclarr.TrashGuide;
|
||
2 years ago
|
|
||
1 year ago
|
namespace Recyclarr.IntegrationTests;
|
||
2 years ago
|
|
||
|
[TestFixture]
|
||
1 year ago
|
public class ConfigTemplateGuideServiceIntegrationTest : IntegrationTestFixture
|
||
2 years ago
|
{
|
||
|
[Test, AutoMockData]
|
||
|
public void Throw_when_templates_dir_does_not_exist(
|
||
|
ConfigTemplateGuideService sut)
|
||
|
{
|
||
1 year ago
|
var act = () => _ = sut.GetTemplateData();
|
||
2 years ago
|
|
||
1 year ago
|
act.Should().Throw<InvalidDataException>().WithMessage("Recyclarr*templates*");
|
||
2 years ago
|
}
|
||
|
|
||
|
[Test]
|
||
1 year ago
|
public void Normal_behavior()
|
||
2 years ago
|
{
|
||
2 years ago
|
var repo = Resolve<IConfigTemplatesRepo>();
|
||
|
var templateDir = repo.Path;
|
||
1 year ago
|
Fs.AddSameFileFromEmbeddedResource(templateDir.File("templates.json"),
|
||
|
typeof(ConfigTemplateGuideServiceIntegrationTest));
|
||
2 years ago
|
|
||
|
TemplatePath MakeTemplatePath(SupportedServices service, string id, string path)
|
||
|
{
|
||
|
var fsPath = templateDir.File(path);
|
||
|
Fs.AddEmptyFile(fsPath);
|
||
2 years ago
|
return new TemplatePath {Service = service, Id = id, TemplateFile = fsPath, Hidden = false};
|
||
2 years ago
|
}
|
||
|
|
||
|
var expectedPaths = new[]
|
||
|
{
|
||
|
MakeTemplatePath(SupportedServices.Radarr, "hd-bluray-web", "radarr/hd-bluray-web.yml"),
|
||
|
MakeTemplatePath(SupportedServices.Radarr, "uhd-bluray-web", "radarr/uhd-bluray-web.yml"),
|
||
|
MakeTemplatePath(SupportedServices.Sonarr, "web-1080p-v4", "sonarr/web-1080p-v4.yml")
|
||
|
};
|
||
|
|
||
|
var sut = Resolve<ConfigTemplateGuideService>();
|
||
|
|
||
1 year ago
|
var data = sut.GetTemplateData();
|
||
2 years ago
|
data.Should().BeEquivalentTo(expectedPaths, o => o.Excluding(x => x.TemplateFile));
|
||
|
data.Select(x => x.TemplateFile.FullName)
|
||
|
.Should().BeEquivalentTo(expectedPaths.Select(x => x.TemplateFile.FullName));
|
||
|
}
|
||
|
}
|