Skip to content

Commit

Permalink
the end date is set to 1st of next month as the upperbound is excluded (
Browse files Browse the repository at this point in the history
#170)

* the end date is set to 1st of next month as the upperbound is excluded

* Remove the script for eventlogv2 table and rollback to eventlogv1
  • Loading branch information
acn-dgopa authored Dec 16, 2024
1 parent 958ece8 commit d5d8871
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ internal IReadOnlyList<Partition> GetPartitionsForCurrentAndAdjacentMonths()
internal (DateOnly startDate, DateOnly endDate) GetMonthStartAndEndDate(DateOnly date)
{
DateOnly startDate = new DateOnly(date.Year, date.Month, 1);
DateOnly endDate = startDate.AddMonths(1).AddDays(-1);
DateOnly endDate = startDate.AddMonths(1);
return (startDate, endDate);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public void GetPartitionsForCurrentAndAdjacentMonths_ReturnsCorrectPartitions()

// Assert
Assert.Equal(6, partitions.Count);
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m09" && p.StartDate == new DateOnly(2023, 9, 1) && p.EndDate == new DateOnly(2023, 9, 30));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m10" && p.StartDate == new DateOnly(2023, 10, 1) && p.EndDate == new DateOnly(2023, 10, 31));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m11" && p.StartDate == new DateOnly(2023, 11, 1) && p.EndDate == new DateOnly(2023, 11, 30));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m09" && p.StartDate == new DateOnly(2023, 9, 1) && p.EndDate == new DateOnly(2023, 10, 1));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m10" && p.StartDate == new DateOnly(2023, 10, 1) && p.EndDate == new DateOnly(2023, 11, 1));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m11" && p.StartDate == new DateOnly(2023, 11, 1) && p.EndDate == new DateOnly(2023, 12, 1));
}

[Theory]
[InlineData(2023, 10, 15, 2023, 10, 1, 2023, 10, 31)]
[InlineData(2023, 2, 1, 2023, 2, 1, 2023, 2, 28)]
[InlineData(2024, 2, 1, 2024, 2, 1, 2024, 2, 29)] // Leap year
[InlineData(2023, 10, 15, 2023, 10, 1, 2023, 11, 1)]
[InlineData(2023, 2, 1, 2023, 2, 1, 2023, 3, 1)]
[InlineData(2024, 2, 1, 2024, 2, 1, 2024, 3, 1)]
public void GetMonthStartAndEndDate_ReturnsCorrectDates(int year, int month, int day, int expectedStartYear, int expectedStartMonth, int expectedStartDay, int expectedEndYear, int expectedEndMonth, int expectedEndDay)
{
// Arrange
Expand All @@ -55,8 +55,8 @@ public void GetPartitionsForCurrentAndAdjacentMonths_CrossYearBoundary_ReturnsCo

// Assert
Assert.Equal(6, partitions.Count);
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m11" && p.StartDate == new DateOnly(2023, 11, 1) && p.EndDate == new DateOnly(2023, 11, 30));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m12" && p.StartDate == new DateOnly(2023, 12, 1) && p.EndDate == new DateOnly(2023, 12, 31));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2024m01" && p.StartDate == new DateOnly(2024, 1, 1) && p.EndDate == new DateOnly(2024, 1, 31));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m11" && p.StartDate == new DateOnly(2023, 11, 1) && p.EndDate == new DateOnly(2023, 12, 1));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2023m12" && p.StartDate == new DateOnly(2023, 12, 1) && p.EndDate == new DateOnly(2024, 1, 1));
Assert.Contains(partitions, p => p.Name == "eventlogv1_y2024m01" && p.StartDate == new DateOnly(2024, 1, 1) && p.EndDate == new DateOnly(2024, 2, 1));
}
}

0 comments on commit d5d8871

Please sign in to comment.