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.
104 lines
2.9 KiB
104 lines
2.9 KiB
1 year ago
|
using Recyclarr.Compatibility;
|
||
|
using Recyclarr.Compatibility.Sonarr;
|
||
1 year ago
|
using Recyclarr.Config.Models;
|
||
1 year ago
|
using Recyclarr.Tests.TestLibrary;
|
||
2 years ago
|
|
||
1 year ago
|
namespace Recyclarr.Tests.Compatibility.Sonarr;
|
||
2 years ago
|
|
||
|
[TestFixture]
|
||
|
public class SonarrCapabilityEnforcerTest
|
||
|
{
|
||
|
[Test, AutoMockData]
|
||
|
public void Minimum_version_not_met(
|
||
2 years ago
|
[Frozen] ISonarrCapabilityFetcher fetcher,
|
||
2 years ago
|
SonarrCapabilityEnforcer sut)
|
||
|
{
|
||
2 years ago
|
var config = NewConfig.Sonarr();
|
||
1 year ago
|
var min = SonarrCapabilities.MinimumVersion;
|
||
2 years ago
|
|
||
2 years ago
|
fetcher.GetCapabilities(default!).ReturnsForAnyArgs(new SonarrCapabilities
|
||
2 years ago
|
{
|
||
1 year ago
|
Version = new Version(min.Major, min.Minor, min.Build, min.Revision - 1)
|
||
2 years ago
|
});
|
||
|
|
||
|
var act = () => sut.Check(config);
|
||
|
|
||
2 years ago
|
act.Should().ThrowAsync<ServiceIncompatibilityException>().WithMessage("*minimum*");
|
||
2 years ago
|
}
|
||
|
|
||
|
[Test, AutoMockData]
|
||
|
public void Release_profiles_not_allowed_in_v4(
|
||
2 years ago
|
[Frozen] ISonarrCapabilityFetcher fetcher,
|
||
2 years ago
|
SonarrCapabilityEnforcer sut)
|
||
|
{
|
||
2 years ago
|
var config = NewConfig.Sonarr() with
|
||
2 years ago
|
{
|
||
|
ReleaseProfiles = new List<ReleaseProfileConfig>
|
||
|
{
|
||
|
new()
|
||
|
}
|
||
|
};
|
||
|
|
||
2 years ago
|
fetcher.GetCapabilities(default!).ReturnsForAnyArgs(new SonarrCapabilities
|
||
2 years ago
|
{
|
||
|
SupportsCustomFormats = true
|
||
|
});
|
||
|
|
||
|
var act = () => sut.Check(config);
|
||
|
|
||
2 years ago
|
act.Should().ThrowAsync<ServiceIncompatibilityException>().WithMessage("*v3*");
|
||
2 years ago
|
}
|
||
|
|
||
|
[Test, AutoMockData]
|
||
|
public void Custom_formats_not_allowed_in_v3(
|
||
2 years ago
|
[Frozen] ISonarrCapabilityFetcher fetcher,
|
||
2 years ago
|
SonarrCapabilityEnforcer sut)
|
||
|
{
|
||
2 years ago
|
var config = NewConfig.Sonarr() with
|
||
2 years ago
|
{
|
||
|
CustomFormats = new List<CustomFormatConfig>
|
||
|
{
|
||
|
new()
|
||
|
}
|
||
|
};
|
||
|
|
||
2 years ago
|
fetcher.GetCapabilities(default!).ReturnsForAnyArgs(new SonarrCapabilities
|
||
2 years ago
|
{
|
||
|
SupportsCustomFormats = false
|
||
|
});
|
||
|
|
||
|
var act = () => sut.Check(config);
|
||
|
|
||
2 years ago
|
act.Should().ThrowAsync<ServiceIncompatibilityException>().WithMessage("*custom formats*v4*");
|
||
|
}
|
||
|
|
||
|
[Test, AutoMockData]
|
||
|
public void Qualities_not_allowed_in_v3(
|
||
|
[Frozen] ISonarrCapabilityFetcher fetcher,
|
||
|
SonarrCapabilityEnforcer sut)
|
||
|
{
|
||
|
var config = NewConfig.Sonarr() with
|
||
|
{
|
||
|
QualityProfiles = new[]
|
||
|
{
|
||
|
new QualityProfileConfig
|
||
|
{
|
||
|
Qualities = new[]
|
||
|
{
|
||
|
new QualityProfileQualityConfig()
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
fetcher.GetCapabilities(default!).ReturnsForAnyArgs(new SonarrCapabilities
|
||
|
{
|
||
|
SupportsCustomFormats = false
|
||
|
});
|
||
|
|
||
|
var act = () => sut.Check(config);
|
||
|
|
||
|
act.Should().ThrowAsync<ServiceIncompatibilityException>().WithMessage("*qualities*v4*");
|
||
2 years ago
|
}
|
||
|
}
|