using System.IO.Abstractions; using System.IO.Abstractions.Extensions; using Autofac; using Recyclarr.Cli.Console.Commands; using Recyclarr.Cli.TestLibrary; using Recyclarr.TestLibrary.Autofac; using Recyclarr.TrashLib.Config.Listers; using Recyclarr.TrashLib.Repo; namespace Recyclarr.Cli.Tests.Console.Commands; [TestFixture] [Parallelizable(ParallelScope.All)] public class ConfigCommandsIntegrationTest : CliIntegrationFixture { protected override void RegisterTypes(ContainerBuilder builder) { base.RegisterTypes(builder); builder.RegisterMockFor(x => { x.Path.Returns(_ => Fs.CurrentDirectory()); }); } [Test] public async Task Repo_update_is_called_on_config_list() { var repo = Resolve(); // Create this to make ConfigTemplateGuideService happy. It tries to parse this file, but // it won't exist because we don't operate with real Git objects (so a clone never happens). Fs.AddFile(repo.Path.File("templates.json"), new MockFileData("{}")); var sut = Resolve(); await sut.ExecuteAsync(default!, new ConfigListCommand.CliSettings { ListCategory = ConfigCategory.Templates }); await repo.Received().Update(); } [Test] public async Task Repo_update_is_called_on_config_create() { var repo = Resolve(); // Create this to make ConfigTemplateGuideService happy. It tries to parse this file, but // it won't exist because we don't operate with real Git objects (so a clone never happens). Fs.AddFile(repo.Path.File("templates.json"), new MockFileData("{}")); var sut = Resolve(); await sut.ExecuteAsync(default!, new ConfigCreateCommand.CliSettings { TemplatesOption = new[] {"some-template"} }); await repo.Received().Update(); } }