mirror of
https://github.com/Radarr/Radarr
synced 2024-12-27 18:30:45 +00:00
Fixed: Validate TMDb ListId is a valid integer
This commit is contained in:
parent
764d456d49
commit
b43732b343
2 changed files with 40 additions and 2 deletions
|
@ -0,0 +1,38 @@
|
|||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.ImportLists.TMDb.List;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.ImportListTests.TMDb
|
||||
{
|
||||
public class TMDbListSettingsValidatorFixture : CoreTest
|
||||
{
|
||||
[TestCase("")]
|
||||
[TestCase("0")]
|
||||
[TestCase("ls12345678")]
|
||||
[TestCase(null)]
|
||||
public void invalid_listId_should_not_validate(string listId)
|
||||
{
|
||||
var setting = new TMDbListSettings
|
||||
{
|
||||
ListId = listId,
|
||||
};
|
||||
|
||||
setting.Validate().IsValid.Should().BeFalse();
|
||||
setting.Validate().Errors.Should().Contain(c => c.PropertyName == "ListId");
|
||||
}
|
||||
|
||||
[TestCase("1")]
|
||||
[TestCase("706123")]
|
||||
public void valid_listId_should_validate(string listId)
|
||||
{
|
||||
var setting = new TMDbListSettings
|
||||
{
|
||||
ListId = listId,
|
||||
};
|
||||
|
||||
setting.Validate().IsValid.Should().BeTrue();
|
||||
setting.Validate().Errors.Should().NotContain(c => c.PropertyName == "ListId");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using FluentValidation;
|
||||
using FluentValidation;
|
||||
using NzbDrone.Core.Annotations;
|
||||
|
||||
namespace NzbDrone.Core.ImportLists.TMDb.List
|
||||
|
@ -8,7 +8,7 @@ public class TMDbListSettingsValidator : TMDbSettingsBaseValidator<TMDbListSetti
|
|||
public TMDbListSettingsValidator()
|
||||
: base()
|
||||
{
|
||||
RuleFor(c => c.ListId).NotEmpty();
|
||||
RuleFor(c => c.ListId).Matches("^[1-9][0-9]*$").NotEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue