diff --git a/src/Dfe.EarlyYearsQualification.Content/Services/ContentfulContentFilterService.cs b/src/Dfe.EarlyYearsQualification.Content/Services/ContentfulContentFilterService.cs index 14b55d88..2db4ec9e 100644 --- a/src/Dfe.EarlyYearsQualification.Content/Services/ContentfulContentFilterService.cs +++ b/src/Dfe.EarlyYearsQualification.Content/Services/ContentfulContentFilterService.cs @@ -141,7 +141,7 @@ private List FilterQualificationsByDate(int startDateMonth, int s var splitQualificationDate = qualificationDate.Split('-'); if (splitQualificationDate.Length != 2) { - logger.LogError("Found qualification date {QualificationDate} with unexpected format", qualificationDate); + logger.LogError("Qualification date {QualificationDate} has unexpected format", qualificationDate); return (false, 0, 0); } diff --git a/tests/Dfe.EarlyYearsQualification.UnitTests/Services/ContentfulContentFilterServiceTests.cs b/tests/Dfe.EarlyYearsQualification.UnitTests/Services/ContentfulContentFilterServiceTests.cs index 632ab03e..d27c45c9 100644 --- a/tests/Dfe.EarlyYearsQualification.UnitTests/Services/ContentfulContentFilterServiceTests.cs +++ b/tests/Dfe.EarlyYearsQualification.UnitTests/Services/ContentfulContentFilterServiceTests.cs @@ -370,6 +370,43 @@ public async Task GetFilteredQualifications_ContentfulClientThrowsException_Retu filteredQualifications.Should().BeEmpty(); } + [TestMethod] + public async Task GetFilteredQualifications_DataContainsInvalidDateFormat_LogsError() + { + var results = new ContentfulCollection + { + Items = new[] + { + new Qualification( + "EYQ-123", + "test", + "NCFE", + 4, + "Sep15", // We expect Mmm-yy, e.g. "Sep-15" + "Aug-19", + "abc/123/987", + "requirements") + } + }; + + var mockContentfulClient = new Mock(); + mockContentfulClient.Setup(x => x.GetEntries( + It.IsAny>(), + It.IsAny())) + .ReturnsAsync(results); + + var mockQueryBuilder = new MockQueryBuilder(); + var mockLogger = new Mock>(); + var filterService = new ContentfulContentFilterService(mockContentfulClient.Object, mockLogger.Object) + { + QueryBuilder = mockQueryBuilder + }; + + await filterService.GetFilteredQualifications(4, 5, 2016); + + mockLogger.VerifyError("Qualification date Sep15 has unexpected format"); + } + [TestMethod] public async Task GetFilteredQualifications_DataContainsInvalidMonth_LogsError() {