This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -39,3 +39,4 @@ node_modules
|
|||||||
atlas.hcl
|
atlas.hcl
|
||||||
.scannerwork
|
.scannerwork
|
||||||
Backend/logs
|
Backend/logs
|
||||||
|
.worktime.txt
|
||||||
|
|||||||
@@ -8,13 +8,22 @@ import (
|
|||||||
|
|
||||||
func TestGetMonday(t *testing.T) {
|
func TestGetMonday(t *testing.T) {
|
||||||
isMonday, err := time.Parse(time.DateOnly, "2025-07-14")
|
isMonday, err := time.Parse(time.DateOnly, "2025-07-14")
|
||||||
|
isSunday, err := time.Parse(time.DateOnly, "2025-07-20")
|
||||||
notMonday, err := time.Parse(time.DateOnly, "2025-07-16")
|
notMonday, err := time.Parse(time.DateOnly, "2025-07-16")
|
||||||
if err != nil || isMonday.Equal(notMonday) {
|
if err != nil || isMonday.Equal(notMonday) {
|
||||||
t.Errorf("U stupid? %e", err)
|
t.Errorf("U stupid? %e", err)
|
||||||
}
|
}
|
||||||
if GetMonday(isMonday) != isMonday || GetMonday(notMonday) != isMonday {
|
if GetMonday(isMonday) != isMonday {
|
||||||
t.Error("Wrong date conversion!")
|
t.Error("Wrong date conversion!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if GetMonday(notMonday) != isMonday {
|
||||||
|
t.Error("Wrong date conversion (notMonday)!")
|
||||||
|
}
|
||||||
|
|
||||||
|
if GetMonday(isSunday) != isMonday {
|
||||||
|
t.Error("Wrong date conversion (isSunday)!")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFormatDuration(t *testing.T) {
|
func TestFormatDuration(t *testing.T) {
|
||||||
@@ -26,17 +35,40 @@ func TestFormatDuration(t *testing.T) {
|
|||||||
{"30min", time.Duration(30 * time.Minute)},
|
{"30min", time.Duration(30 * time.Minute)},
|
||||||
{"1h 30min", time.Duration(90 * time.Minute)},
|
{"1h 30min", time.Duration(90 * time.Minute)},
|
||||||
{"-1h 30min", time.Duration(-90 * time.Minute)},
|
{"-1h 30min", time.Duration(-90 * time.Minute)},
|
||||||
{"", 0},
|
{"0min", 0},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
if FormatDuration(tc.duration) != tc.name {
|
if FormatDurationFill(tc.duration, true) != tc.name {
|
||||||
t.Error("Format missmatch in Formatduration.")
|
t.Error("Format missmatch in Formatduration.")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIsSameDate(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
dateA string
|
||||||
|
dateB string
|
||||||
|
result bool
|
||||||
|
}{
|
||||||
|
{"2025-12-01 00:00:00", "2025-12-01 00:00:00", true},
|
||||||
|
{"2025-12-03 00:00:00", "2025-12-02 00:00:00", false},
|
||||||
|
{"2025-12-03 23:45:00", "2025-12-03 00:00:00", true},
|
||||||
|
{"2025-12-04 24:12:00", "2025-12-04 00:12:00", false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(fmt.Sprintf("IsSameDateTest: %s date", tc.dateA), func(t *testing.T) {
|
||||||
|
dateA, _ := time.Parse(time.DateTime, tc.dateA)
|
||||||
|
dateB, _ := time.Parse(time.DateTime, tc.dateB)
|
||||||
|
if IsSameDate(dateA, dateB) != tc.result {
|
||||||
|
t.Errorf("Is SameDate did not match! Result %t", IsSameDate(dateA, dateB))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestGetWorkingDays(t *testing.T) {
|
func TestGetWorkingDays(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
start string
|
start string
|
||||||
|
|||||||
Reference in New Issue
Block a user