Skip to content

Commit

Permalink
EES-5238 - correcting name of orchestration and adding missing test
Browse files Browse the repository at this point in the history
  • Loading branch information
duncan-at-hiveit committed Jul 16, 2024
1 parent ffc5b96 commit ad59299
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using GovUk.Education.ExploreEducationStatistics.Common.Extensions;
using GovUk.Education.ExploreEducationStatistics.Common.Tests.Extensions;
using GovUk.Education.ExploreEducationStatistics.Common.Utils;
using GovUk.Education.ExploreEducationStatistics.Content.Model;
using GovUk.Education.ExploreEducationStatistics.Content.Model.Database;
using GovUk.Education.ExploreEducationStatistics.Content.Model.Tests.Fixtures;
Expand Down Expand Up @@ -30,6 +31,17 @@ public class CompleteNextDataSetVersionImportTests(
ProcessorFunctionsIntegrationTestFixture fixture)
: CompleteNextDataSetVersionImportFunctionTests(fixture)
{
public static TheoryData<DataSetVersionStatus> NonMappingDataSetVersionStatuses =
new(EnumUtil
.GetEnums<DataSetVersionStatus>()
.Except([DataSetVersionStatus.Mapping]));

public static TheoryData<DataSetVersionImportStage> NonManualMappingStages =
new(EnumUtil
.GetEnums<DataSetVersionImportStage>()
.Except([DataSetVersionImportStage.ManualMapping]));


[Fact]
public async Task Success()
{
Expand All @@ -42,7 +54,7 @@ public async Task Success()
durableTaskClientMock.Setup(client =>
client.ScheduleNewOrchestrationInstanceAsync(
nameof(ProcessCompletionOfNextDataSetVersionFunction
.CompleteNextDataSetVersionImportProcessing),
.ProcessCompletionOfNextDataSetVersion),
It.IsAny<ProcessDataSetVersionContext>(),
It.IsAny<StartOrchestrationOptions>(),
It.IsAny<CancellationToken>()))
Expand Down Expand Up @@ -71,6 +83,9 @@ public async Task Success()

var responseViewModel = result.AssertOkObjectResult<ProcessDataSetVersionResponseViewModel>();

Assert.Equal(nextVersion.Id, responseViewModel.DataSetVersionId);
Assert.Equal(nextVersion.DataSetId, responseViewModel.DataSetId);

// Assert that the pre-existing import entry for the next data set version is re-used.
var updatedDataSetVersionImport = publicDataDbContext
.DataSetVersionImports
Expand Down Expand Up @@ -119,8 +134,10 @@ public async Task DataSetVersionIsNotFound_ReturnsNotFound()
expectedPath: nameof(NextDataSetVersionCompleteImportRequest.DataSetVersionId).ToLowerFirst());
}

[Fact]
public async Task DataSetVersionNotInMappingStatus_ReturnsValidationProblem()
[Theory]
[MemberData(nameof(NonMappingDataSetVersionStatuses))]
public async Task DataSetVersionNotInMappingStatus_ReturnsValidationProblem(
DataSetVersionStatus status)
{
var (_, _, nextVersion) = await AddDataSetAndLatestLiveAndNextVersion();

Expand All @@ -131,7 +148,7 @@ public async Task DataSetVersionNotInMappingStatus_ReturnsValidationProblem()
.DataSetVersions
.SingleAsync(dsv => dsv.Id == nextVersion.Id);

nextVersionWithIncorrectStatus.Status = DataSetVersionStatus.Draft;
nextVersionWithIncorrectStatus.Status = status;

await publicDataDbContext.SaveChangesAsync();

Expand Down Expand Up @@ -221,8 +238,10 @@ public async Task DataSetVersionMappings_FilterOptionsNotComplete_ReturnsValidat
expectedCode: ValidationMessages.DataSetVersionMappingsNotComplete.Code);
}

[Fact]
public async Task DataSetVersionImportInManualMappingStateNotFound_ReturnsValidationProblem()
[Theory]
[MemberData(nameof(NonManualMappingStages))]
public async Task DataSetVersionImportInManualMappingStateNotFound_ReturnsValidationProblem(
DataSetVersionImportStage importStage)
{
var (_, _, nextVersion) = await AddDataSetAndLatestLiveAndNextVersion();

Expand All @@ -233,7 +252,7 @@ public async Task DataSetVersionImportInManualMappingStateNotFound_ReturnsValida
.DataSetVersionImports
.SingleAsync(import => import.DataSetVersionId == nextVersion.Id);

importWithIncorrectStatus.Stage = DataSetVersionImportStage.AutoMapping;
importWithIncorrectStatus.Stage = importStage;

await publicDataDbContext.SaveChangesAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private static Mock<TaskOrchestrationContext> DefaultMockOrchestrationContext(
}
}

public class CompleteInitialDataSetVersionProcessingTests(
public class CompleteNextDataSetVersionImportProcessingTests(
ProcessorFunctionsIntegrationTestFixture fixture)
: ProcessCompletionOfNextDataSetVersionImportFunctionTests(fixture)
{
Expand Down Expand Up @@ -177,8 +177,8 @@ public async Task DuckDbFileIsDeleted()

private async Task CompleteProcessing(Guid instanceId)
{
var function = GetRequiredService<ProcessInitialDataSetVersionFunction>();
await function.CompleteInitialDataSetVersionProcessing(instanceId, CancellationToken.None);
var function = GetRequiredService<ProcessCompletionOfNextDataSetVersionFunction>();
await function.CompleteNextDataSetVersionImportProcessing(instanceId, CancellationToken.None);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private async Task ProcessCompletionOfNextDataSetVersionImport(
CancellationToken cancellationToken)
{
const string orchestratorName =
nameof(ProcessCompletionOfNextDataSetVersionFunction.CompleteNextDataSetVersionImportProcessing);
nameof(ProcessCompletionOfNextDataSetVersionFunction.ProcessCompletionOfNextDataSetVersion);

var input = new ProcessDataSetVersionContext { DataSetVersionId = dataSetVersionId };

Expand Down

0 comments on commit ad59299

Please sign in to comment.