Skip to content

Commit

Permalink
Merge branch 'v2' into calculate-lastrun
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRoesler committed Mar 26, 2024
2 parents 2850d80 + 5b1cf9c commit ce89182
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var (
ErrDailyJobAtTimesNil = fmt.Errorf("gocron: DailyJob: atTimes must not be nil")
ErrDailyJobHours = fmt.Errorf("gocron: DailyJob: atTimes hours must be between 0 and 23 inclusive")
ErrDailyJobMinutesSeconds = fmt.Errorf("gocron: DailyJob: atTimes minutes and seconds must be between 0 and 59 inclusive")
ErrDurationJobIntervalZero = fmt.Errorf("gocron: DurationJob: time interval is 0")
ErrDurationRandomJobMinMax = fmt.Errorf("gocron: DurationRandomJob: minimum duration must be less than maximum duration")
ErrEventListenerFuncNil = fmt.Errorf("gocron: eventListenerFunc must not be nil")
ErrJobNotFound = fmt.Errorf("gocron: job not found")
Expand Down
3 changes: 3 additions & 0 deletions job.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ type durationJobDefinition struct {
}

func (d durationJobDefinition) setup(j *internalJob, _ *time.Location) error {
if d.duration == 0 {
return ErrDurationJobIntervalZero
}
j.jobSchedule = &durationJob{duration: d.duration}
return nil
}
Expand Down
6 changes: 6 additions & 0 deletions scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,12 @@ func TestScheduler_NewJobErrors(t *testing.T) {
nil,
ErrCronJobParse,
},
{
"duration job time interval is zero",
DurationJob(0 * time.Second),
nil,
ErrDurationJobIntervalZero,
},
{
"random with bad min/max",
DurationRandomJob(
Expand Down

0 comments on commit ce89182

Please sign in to comment.