mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
Fixed the unit tests and they will now break the build if they fail
This commit is contained in:
parent
abf4a424b3
commit
9e945b9083
6 changed files with 31 additions and 7 deletions
|
@ -31,4 +31,4 @@ steps:
|
|||
command: 'custom'
|
||||
projects: '$(TestProject)'
|
||||
custom: 'test'
|
||||
continueOnError: true
|
||||
continueOnError: false
|
||||
|
|
|
@ -18,7 +18,8 @@ namespace Ombi.Core.Tests.Rule.Request
|
|||
{
|
||||
private List<OmbiUser> _users = new List<OmbiUser>
|
||||
{
|
||||
new OmbiUser { Id = Guid.NewGuid().ToString("N"), UserName="abc",UserType = UserType.LocalUser}
|
||||
new OmbiUser { Id = Guid.NewGuid().ToString("N"), UserName="abc", NormalizedUserName = "ABC", UserType = UserType.LocalUser},
|
||||
new OmbiUser { Id = Guid.NewGuid().ToString("N"), UserName="Sys", NormalizedUserName = "SYS", UserType = UserType.SystemUser}
|
||||
};
|
||||
|
||||
[SetUp]
|
||||
|
@ -92,6 +93,18 @@ namespace Ombi.Core.Tests.Rule.Request
|
|||
Assert.True(request.Approved);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Should_ReturnSuccess_WhenSystemUserAndRequestTV()
|
||||
{
|
||||
PrincipalMock.Setup(x => x.Identity.Name).Returns("sys");
|
||||
UserManager.Setup(x => x.IsInRoleAsync(It.IsAny<OmbiUser>(), OmbiRoles.AutoApproveTv)).ReturnsAsync(false);
|
||||
var request = new BaseRequest() { RequestType = Store.Entities.RequestType.TvShow };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
Assert.True(result.Success);
|
||||
Assert.True(request.Approved);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Should_ReturnFail_WhenAutoApproveTV_And_RequestMovie()
|
||||
{
|
||||
|
|
|
@ -18,7 +18,8 @@ namespace Ombi.Core.Tests.Rule.Request
|
|||
{
|
||||
private List<OmbiUser> _users = new List<OmbiUser>
|
||||
{
|
||||
new OmbiUser { Id = Guid.NewGuid().ToString("N"), UserName="abc", UserType = UserType.LocalUser}
|
||||
new OmbiUser { Id = Guid.NewGuid().ToString("N"), UserName="abc", NormalizedUserName = "ABC", UserType = UserType.LocalUser},
|
||||
new OmbiUser { Id = Guid.NewGuid().ToString("N"), UserName="sys", NormalizedUserName = "SYS", UserType = UserType.SystemUser}
|
||||
};
|
||||
|
||||
[SetUp]
|
||||
|
@ -68,6 +69,17 @@ namespace Ombi.Core.Tests.Rule.Request
|
|||
Assert.True(result.Success);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Should_ReturnSuccess_WhenRequestingMovieWithSystemRole()
|
||||
{
|
||||
PrincipalMock.Setup(x => x.Identity.Name).Returns("sys");
|
||||
UserManager.Setup(x => x.IsInRoleAsync(It.IsAny<OmbiUser>(), OmbiRoles.Admin)).ReturnsAsync(false);
|
||||
var request = new BaseRequest() { RequestType = Store.Entities.RequestType.Movie };
|
||||
var result = await Rule.Execute(request);
|
||||
|
||||
Assert.True(result.Success);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Should_ReturnSuccess_WhenRequestingTVWithAdminRole()
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@ using MockQueryable.Moq;
|
|||
using Moq;
|
||||
using Ombi.Core.Authentication;
|
||||
using Ombi.Store.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
|
||||
<PackageReference Include="Moq" Version="4.10.0" />
|
||||
<PackageReference Include="MockQueryable.Moq" Version="1.1.0" />
|
||||
<PackageReference Include="MockQueryable.Moq" Version="3.1.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -7,10 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi", "Ombi\Ombi.csproj",
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9D30CCF8-A115-4EB7-A34D-07780D752789}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
..\appveyor.yml = ..\appveyor.yml
|
||||
..\.azuredevops\pipelines\templates\build-steps.yml = ..\.azuredevops\pipelines\templates\build-steps.yml
|
||||
..\build.cake = ..\build.cake
|
||||
..\CHANGELOG.md = ..\CHANGELOG.md
|
||||
..\ci-build.yaml = ..\ci-build.yaml
|
||||
..\.azuredevops\pipelines\publish-job.yml = ..\.azuredevops\pipelines\publish-job.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Core", "Ombi.Core\Ombi.Core.csproj", "{F56E79C7-791D-4668-A0EC-29E3BBC8D24B}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue