Extract Month class

This commit is contained in:
2022-04-06 21:41:55 +00:00
parent 01c407d4f1
commit 54e591bc5e
5 changed files with 97 additions and 37 deletions

View File

@ -181,9 +181,8 @@ func AssertCategoriesAndAvailableEqual(ctx context.Context, t *testing.T, loc *t
}
year, _ := strconv.Atoi(parts[0])
month, _ := strconv.Atoi(parts[1])
first := time.Date(year, time.Month(month), 1, 0, 0, 0, 0, loc)
testCaseFile := filepath.Join(resultDir, file.Name())
handler.CheckAvailableBalance(ctx, t, testCaseFile, budget, first)
handler.CheckAvailableBalance(ctx, t, testCaseFile, budget, Month{year, month})
}
})
}
@ -199,12 +198,12 @@ type CategoryTestData struct {
Assigned float64
}
func (h Handler) CheckAvailableBalance(ctx context.Context, t *testing.T, testCaseFile string, budget *postgres.Budget, first time.Time) {
func (h Handler) CheckAvailableBalance(ctx context.Context, t *testing.T, testCaseFile string, budget *postgres.Budget, month Month) {
t.Helper()
t.Run(first.Format("2006-01"), func(t *testing.T) {
t.Run(month.String(), func(t *testing.T) {
t.Parallel()
data, err := h.prepareBudgeting(ctx, *budget, first)
data, err := h.getBudgetingViewForMonth(ctx, *budget, month)
if err != nil {
t.Errorf("prepare budgeting: %s", err)
return