Skip to content

Commit

Permalink
psp-9512 tests and jobs for polling, uploads, and retries.
Browse files Browse the repository at this point in the history
  • Loading branch information
devinleighsmith committed Dec 20, 2024
1 parent 1d607f4 commit 684ef57
Show file tree
Hide file tree
Showing 60 changed files with 3,822 additions and 1,759 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci-cd-pims-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ jobs:
- name: Deploy mayan
shell: bash
run: |
./openshift/4.0/player.sh deploy scheduler $DESTINATION -apply
oc tag mayan-bcgov:latest-$DESTINATION mayan-bcgov:$DESTINATION
# the command:
Expand Down
31 changes: 31 additions & 0 deletions source/backend/Pims.Scheduler.Test/Pims.Scheduler.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\scheduler\Pims.Scheduler.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using FluentAssertions;
using Moq;
using Pims.Api.Models.CodeTypes;
using Pims.Api.Models.Concepts.Document;
using Pims.Api.Models.Requests.Http;
using Pims.Dal.Entities.Models;
using Pims.Scheduler.Repositories;
using Xunit;

namespace Pims.Scheduler.Test.Repositories
{
public class PimsDocumentQueueRepositoryTest
{
[Fact]
public async Task PollQueuedDocument_ValidDocument_ReturnsExternalResponse()
{
// Arrange
var document = new DocumentQueueModel { Id = 1 };
var expectedResponse = new ExternalResponse<DocumentQueueModel> { Status = ExternalResponseStatus.Success };
var repositoryMock = new Mock<IPimsDocumentQueueRepository>();
repositoryMock.Setup(x => x.PollQueuedDocument(document)).ReturnsAsync(expectedResponse);

// Act
var result = await repositoryMock.Object.PollQueuedDocument(document);

// Assert
result.Should().NotBeNull();
result.Status.Should().Be(ExternalResponseStatus.Success);
repositoryMock.Verify(x => x.PollQueuedDocument(document), Times.Once);
}

[Fact]
public async Task UploadQueuedDocument_ValidDocument_ReturnsExternalResponse()
{
// Arrange
var document = new DocumentQueueModel { Id = 1 };
var expectedResponse = new ExternalResponse<DocumentQueueModel> { Status = ExternalResponseStatus.Success };
var repositoryMock = new Mock<IPimsDocumentQueueRepository>();
repositoryMock.Setup(x => x.UploadQueuedDocument(document)).ReturnsAsync(expectedResponse);

// Act
var result = await repositoryMock.Object.UploadQueuedDocument(document);

// Assert
result.Should().NotBeNull();
result.Status.Should().Be(ExternalResponseStatus.Success);
repositoryMock.Verify(x => x.UploadQueuedDocument(document), Times.Once);
}

[Fact]
public async Task UpdateQueuedDocument_ValidDocument_ReturnsExternalResponse()
{
// Arrange
var documentQueueId = 1;
var document = new DocumentQueueModel { Id = documentQueueId };
var expectedResponse = new ExternalResponse<DocumentQueueModel> { Status = ExternalResponseStatus.Success };
var repositoryMock = new Mock<IPimsDocumentQueueRepository>();
repositoryMock.Setup(x => x.UpdateQueuedDocument(documentQueueId, document)).ReturnsAsync(expectedResponse);

// Act
var result = await repositoryMock.Object.UpdateQueuedDocument(documentQueueId, document);

// Assert
result.Should().NotBeNull();
result.Status.Should().Be(ExternalResponseStatus.Success);
repositoryMock.Verify(x => x.UpdateQueuedDocument(documentQueueId, document), Times.Once);
}

[Fact]
public async Task SearchQueuedDocumentsAsync_ValidFilter_ReturnsExternalResponse()
{
// Arrange
var filter = new DocumentQueueFilter();
var expectedResponse = new ExternalResponse<List<DocumentQueueModel>> { Status = ExternalResponseStatus.Success };
var repositoryMock = new Mock<IPimsDocumentQueueRepository>();
repositoryMock.Setup(x => x.SearchQueuedDocumentsAsync(filter)).ReturnsAsync(expectedResponse);

// Act
var result = await repositoryMock.Object.SearchQueuedDocumentsAsync(filter);

// Assert
result.Should().NotBeNull();
result.Status.Should().Be(ExternalResponseStatus.Success);
repositoryMock.Verify(x => x.SearchQueuedDocumentsAsync(filter), Times.Once);
}
}
}
Loading

0 comments on commit 684ef57

Please sign in to comment.