-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Dynamic shift of working hours don't exceed end time or precede…
… start time
- Loading branch information
Showing
3 changed files
with
64 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package utils | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
) | ||
|
||
// Test value is within the range of 3 to 14 minutes | ||
func TestGenerateTimeInterval(t *testing.T) { | ||
for range 100 { | ||
result := generateTimeInterval() | ||
if result < 3*time.Minute || result >= 15*time.Minute { | ||
t.Errorf("generateTimeInterval() = %v, want %v to %v", result, 3*time.Minute, 15*time.Minute) | ||
} | ||
} | ||
} | ||
|
||
// Test checks if the function merges two times correctly | ||
func TestCombineNowAndShiftTime(t *testing.T) { | ||
now := time.Date(2024, 4, 7, 10, 0, 45, 0, time.UTC) | ||
shiftTime := time.Date(2000, 1, 1, 15, 30, 0, 0, time.UTC) | ||
expected := time.Date(2024, 4, 7, 15, 30, 45, 0, time.UTC) | ||
result := combineNowAndShiftTime(now, shiftTime) | ||
|
||
if !result.Equal(expected) { | ||
t.Errorf("combineNowAndShiftTime(%v, %v) = %v, want %v", now, shiftTime, result, expected) | ||
} | ||
} |