Skip to content

Commit

Permalink
Merge pull request #5377 from dfe-analytical-services/EES-5583
Browse files Browse the repository at this point in the history
EES-5547: Display info modal for bulk imports before the actual imports start
  • Loading branch information
tomjonesdev authored Dec 6, 2024
2 parents e636e43 + dc0e17f commit 12a40d7
Show file tree
Hide file tree
Showing 28 changed files with 878 additions and 801 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,72 @@ public async Task CreateReleaseAmendment()
result.AssertOkResult(amendmentCreatedResponse);
}

[Fact]
public async Task UploadBulkZipDataSetsToTempStorage()
{
// Arrange
var dataSetFiles = new List<ArchiveDataSetFileViewModel>();

var releaseDataFileService = new Mock<IReleaseDataFileService>(Strict);

releaseDataFileService
.Setup(s => s.ValidateAndUploadBulkZip(
It.IsAny<Guid>(),
It.IsAny<IFormFile>(),
default))
.ReturnsAsync(dataSetFiles);

var controller = BuildController(releaseDataFileService: releaseDataFileService.Object);

// Act
var result = await controller.UploadBulkZipDataSetsToTempStorage(
Guid.NewGuid(),
MockFile("bulk.zip"),
default);

// Assert
VerifyAllMocks(releaseDataFileService);

result.AssertOkResult(dataSetFiles);
}

[Fact]
public async Task ImportBulkZipDataSetsFromTempStorage()
{
// Arrange
var dataFileInfo = new List<DataFileInfo>
{
new() { FileName = "one.csv", Name = "Data set title", Size = "1024" },
};

var importRequests = new List<ArchiveDataSetFileViewModel>
{
new(){ DataFileId = Guid.NewGuid(), MetaFileId = Guid.NewGuid(), Title = "Data set title", DataFilename = "one.csv", MetaFilename = "one.meta.csv", DataFileSize = 1024, MetaFileSize = 128 }
};

var releaseDataFileService = new Mock<IReleaseDataFileService>(Strict);

releaseDataFileService
.Setup(s => s.SaveDataSetsFromTemporaryBlobStorage(
It.IsAny<Guid>(),
It.IsAny<List<ArchiveDataSetFileViewModel>>(),
default))
.ReturnsAsync(dataFileInfo);

var controller = BuildController(releaseDataFileService: releaseDataFileService.Object);

// Act
var result = await controller.ImportBulkZipDataSetsFromTempStorage(
Guid.NewGuid(),
importRequests,
default);

// Assert
VerifyAllMocks(releaseDataFileService);

result.AssertOkResult(dataFileInfo);
}

private static IFormFile MockFile(string fileName)
{
var fileMock = new Mock<IFormFile>(Strict);
Expand Down
Loading

0 comments on commit 12a40d7

Please sign in to comment.