fixed #60
Some checks failed
Arbeitszeitmessung Deploy / Run Go Tests (push) Successful in 1m29s
Tests / Run Go Tests (push) Has been cancelled
Arbeitszeitmessung Deploy / Build Go Image and Upload (push) Successful in 2m7s

This commit is contained in:
2025-12-02 16:53:43 +01:00
parent 5a5e776e8b
commit 74bce88cc0
6 changed files with 43 additions and 12 deletions

View File

@@ -18,7 +18,7 @@ func TestGetMonday(t *testing.T) {
}
func TestFormatDuration(t *testing.T) {
durations := []struct {
testCases := []struct {
name string
duration time.Duration
}{
@@ -28,9 +28,9 @@ func TestFormatDuration(t *testing.T) {
{"-1h 30min", time.Duration(-90 * time.Minute)},
{"", 0},
}
for _, d := range durations {
t.Run(d.name, func(t *testing.T) {
if FormatDuration(d.duration) != d.name {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if FormatDuration(tc.duration) != tc.name {
t.Error("Format missmatch in Formatduration.")
}
})
@@ -58,3 +58,27 @@ func TestGetWorkingDays(t *testing.T) {
})
}
}
func TestFormatGermanDayOfWeek(t *testing.T) {
testCases := []struct {
date string
result string
}{
{"2025-12-01", "Mo"},
{"2025-12-02", "Di"},
{"2025-12-03", "Mi"},
{"2025-12-04", "Do"},
{"2025-12-05", "Fr"},
{"2025-12-06", "Sa"},
{"2025-12-07", "So"},
}
for _, tc := range testCases {
t.Run(fmt.Sprintf("FormatWeekDayTest: %s date", tc.date), func(t *testing.T) {
date, _ := time.Parse(time.DateOnly, tc.date)
if FormatGermanDayOfWeek(date) != tc.result {
t.Error("Formatted workday did not match!")
}
})
}
}