added interface for workday and absence + multiday absences closes #38, #39

This commit is contained in:
2025-09-23 12:30:02 +02:00
parent 55b0332600
commit db6fc10c28
19 changed files with 1396 additions and 1034 deletions

View File

@@ -20,11 +20,10 @@ var testWorkDay = models.WorkDay{
Bookings: testBookings8hrs,
TimeFrom: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 08:00")),
TimeTo: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 16:30")),
Absence: models.Absence{},
}
func TestCalcRealWorkTime(t *testing.T) {
workTime := testWorkDay.CalcRealWorkTime(testUser)
workTime := testWorkDay.TimeWorkReal(testUser)
if workTime != time.Hour*8 {
t.Errorf("Calc Worktime Default not working, time should be 8h, but was %s", helper.FormatDuration(workTime))
}
@@ -64,10 +63,10 @@ func TestCalcWorkPauseDiff(t *testing.T) {
for _, test := range testCases {
t.Run(test.Name, func(t *testing.T) {
testWorkDay.Bookings = test.bookings
testWorkDay.CalcRealWorkTime(testUser)
testWorkDay.CalcWorkPauseDiff(testUser)
testWorkDay.CalcOvertime(testUser)
workTime, pauseTime, overTime := testWorkDay.GetAllWorkTimes(testUser)
testWorkDay.TimeWorkReal(testUser)
testWorkDay.TimePauseReal(testUser)
testWorkDay.TimeOvertimeReal(testUser)
workTime, pauseTime, overTime := testWorkDay.GetAllWorkTimesReal(testUser)
if workTime != test.expectedWorkTime {
t.Errorf("Calculated wrong workTime: should be %s, but was %s", helper.FormatDuration(test.expectedWorkTime), helper.FormatDuration(workTime))
}