seperated pdf-generate endpoint + added new helper in Time
This commit is contained in:
@@ -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")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user