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.
55 lines
1.7 KiB
55 lines
1.7 KiB
2 years ago
|
using System.Text.RegularExpressions;
|
||
1 year ago
|
using Recyclarr.Cli.Migration.Steps;
|
||
|
using Recyclarr.TestLibrary.AutoFixture;
|
||
2 years ago
|
|
||
1 year ago
|
namespace Recyclarr.Cli.Tests.Migration.Steps;
|
||
2 years ago
|
|
||
|
[TestFixture]
|
||
|
[Parallelizable(ParallelScope.All)]
|
||
|
public class MigrateTrashYmlTest
|
||
|
{
|
||
|
private static readonly string BasePath = AppContext.BaseDirectory;
|
||
|
|
||
|
[Test, AutoMockData]
|
||
|
public void Migration_check_returns_true_if_trash_yml_exists(
|
||
|
[Frozen(Matching.ImplementedInterfaces)] MockFileSystem fs,
|
||
|
MigrateTrashYml sut)
|
||
|
{
|
||
2 years ago
|
fs.AddFile(Path.Combine(BasePath, "trash.yml"), new MockFileData(""));
|
||
2 years ago
|
sut.CheckIfNeeded().Should().BeTrue();
|
||
|
}
|
||
|
|
||
|
[Test, AutoMockData]
|
||
|
public void Migration_check_returns_false_if_trash_yml_doesnt_exists(
|
||
|
[Frozen(Matching.ImplementedInterfaces)] MockFileSystem fs,
|
||
|
MigrateTrashYml sut)
|
||
|
{
|
||
|
sut.CheckIfNeeded().Should().BeFalse();
|
||
|
}
|
||
|
|
||
|
[Test, AutoMockData]
|
||
|
public void Migration_throws_if_recyclarr_yml_already_exists(
|
||
|
[Frozen(Matching.ImplementedInterfaces)] MockFileSystem fs,
|
||
|
MigrateTrashYml sut)
|
||
|
{
|
||
2 years ago
|
fs.AddFile(Path.Combine(BasePath, "recyclarr.yml"), new MockFileData(""));
|
||
2 years ago
|
|
||
2 years ago
|
var act = () => sut.Execute(null);
|
||
2 years ago
|
|
||
2 years ago
|
act.Should().Throw<IOException>();
|
||
2 years ago
|
}
|
||
|
|
||
|
[Test, AutoMockData]
|
||
|
public void Migration_success(
|
||
|
[Frozen(Matching.ImplementedInterfaces)] MockFileSystem fs,
|
||
|
MigrateTrashYml sut)
|
||
|
{
|
||
|
const string expectedData = "fake contents";
|
||
|
fs.AddFile(Path.Combine(BasePath, "trash.yml"), expectedData);
|
||
|
|
||
2 years ago
|
sut.Execute(null);
|
||
2 years ago
|
|
||
|
fs.AllFiles.Should().ContainSingle(x => Regex.IsMatch(x, @"[/\\]recyclarr\.yml$"));
|
||
|
}
|
||
|
}
|