upped test coverage of helpers
Some checks failed
Tests / Run Go Tests (push) Failing after 1m27s

This commit is contained in:
2025-12-03 00:38:26 +01:00
parent 386f11ec7e
commit a6ea625e8f
4 changed files with 240 additions and 1 deletions

View File

@@ -26,7 +26,7 @@ func TestGetMonday(t *testing.T) {
}
}
func TestFormatDuration(t *testing.T) {
func TestFormatDurationFill(t *testing.T) {
testCases := []struct {
name string
duration time.Duration
@@ -48,6 +48,22 @@ func TestFormatDuration(t *testing.T) {
}
}
func TestFormatDuration(t *testing.T) {
testCases := []struct {
name string
duration time.Duration
}{
{"", 0},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if FormatDuration(tc.duration) != tc.name {
t.Error("Format missmatch in Formatduration.")
}
})
}
}
func TestIsSameDate(t *testing.T) {
testCases := []struct {
dateA string
@@ -116,3 +132,41 @@ func TestFormatGermanDayOfWeek(t *testing.T) {
})
}
}
func TestGetKW(t *testing.T) {
tests := []struct {
name string
date time.Time
want int
}{
{
name: "First week of year",
date: time.Date(2023, 1, 2, 0, 0, 0, 0, time.UTC), // Monday
want: 1,
},
{
name: "Middle of year",
date: time.Date(2023, 6, 15, 0, 0, 0, 0, time.UTC),
want: 24,
},
{
name: "Last week of year",
date: time.Date(2023, 12, 31, 0, 0, 0, 0, time.UTC),
want: 52,
},
{
name: "ISO week crossing into next year",
date: time.Date(2020, 12, 31, 0, 0, 0, 0, time.UTC),
want: 53,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := GetKW(tt.date)
if got != tt.want {
t.Errorf("GetKW(%v) = %d, want %d", tt.date, got, tt.want)
}
})
}
}