Limit all dates asking to 3 months range

This commit is contained in:
Guntis Smaukstelis
2023-08-11 16:22:15 +03:00
parent a52eb2c54f
commit f1e68c6dba
7 changed files with 86 additions and 12 deletions
+21
View File
@@ -34,6 +34,27 @@ class DBServiceSpec extends AnyFunSuite with Matchers {
lines.length shouldBe 2142
}
test("getDatesByMonths should return filtered dates") {
val monthFormatter = DateTimeFormatter.ofPattern("yyyyMMdd")
val monthList = List(
LocalDate.parse("20230401", monthFormatter),
LocalDate.parse("20230501", monthFormatter),
LocalDate.parse("20230601", monthFormatter),
)
val dbService = DBService.of.unsafeRunSync()
val dates = dbService.getDatesByMonths(monthList).unsafeRunSync()
dates should not be empty
val exportFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val validPrefixes = Set("2023-04", "2023-05", "2023-06")
val invalidDates = dates
.map(_.format(exportFormatter))
.filterNot(date => validPrefixes.exists(prefix => date.startsWith(prefix)))
invalidDates shouldBe empty
}
test("DBService.save should return correct result") {
val dbService = DBService.of.unsafeRunSync()
val fileName = "testFile.txt"