Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRoesler committed Jan 3, 2025
1 parent 7f6e385 commit fb81b1b
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,3 +724,59 @@ func TestTimeFromAtTime(t *testing.T) {
})
}
}

func TestNewAtTimes(t *testing.T) {
at := NewAtTimes(
NewAtTime(1, 1, 1),
NewAtTime(2, 2, 2),
)

var times []string
for _, att := range at() {
timeStr := TimeFromAtTime(att, time.UTC).Format("15:04")
times = append(times, timeStr)
}

var timesAgain []string
for _, att := range at() {
timeStr := TimeFromAtTime(att, time.UTC).Format("15:04")
timesAgain = append(timesAgain, timeStr)
}

assert.Equal(t, times, timesAgain)
}

func TestNewWeekdays(t *testing.T) {
wd := NewWeekdays(
time.Monday,
time.Tuesday,
)

var dayStrings []string
for _, w := range wd() {
dayStrings = append(dayStrings, w.String())
}

var dayStringsAgain []string
for _, w := range wd() {
dayStringsAgain = append(dayStringsAgain, w.String())
}

assert.Equal(t, dayStrings, dayStringsAgain)
}

func TestNewDaysOfTheMonth(t *testing.T) {
dom := NewDaysOfTheMonth(1, 2, 3)

var domInts []int
for _, d := range dom() {
domInts = append(domInts, d)
}

var domIntsAgain []int
for _, d := range dom() {
domIntsAgain = append(domIntsAgain, d)
}

assert.Equal(t, domInts, domIntsAgain)
}

0 comments on commit fb81b1b

Please sign in to comment.