seperated pdf-generate endpoint + added new helper in Time

This commit is contained in:
2025-10-28 22:59:33 +01:00
parent 4bc5594dc5
commit cf5238f024
6 changed files with 104 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
package helper
import (
"fmt"
"testing"
"time"
)
@@ -35,3 +36,25 @@ func TestFormatDuration(t *testing.T) {
})
}
}
func TestGetWorkingDays(t *testing.T) {
testCases := []struct {
start string
end string
days int
}{
{"2025-10-01", "2025-10-02", 2},
{"2025-10-02", "2025-10-01", 0},
{"2025-10-01", "2025-10-31", 23},
}
for _, tc := range testCases {
t.Run(fmt.Sprintf("WorkingDayTest: %d days", tc.days), func(t *testing.T) {
startDate, _ := time.Parse(time.DateOnly, tc.start)
endDate, _ := time.Parse(time.DateOnly, tc.end)
if GetWorkingDays(startDate, endDate) != tc.days {
t.Error("Calculated workdays do not match target")
}
})
}
}