File tree Expand file tree Collapse file tree 3 files changed +12
-0
lines changed
Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Original file line number Diff line number Diff line change 5959 ErrStartTimeLaterThanEndTime = errors .New ("gocron: WithStartDateTime: start must not be later than end" )
6060 ErrStopTimeEarlierThanStartTime = errors .New ("gocron: WithStopDateTime: end must not be earlier than start" )
6161 ErrWithStopTimeoutZeroOrNegative = errors .New ("gocron: WithStopTimeout: timeout must be greater than 0" )
62+ ErrWithLimitedRunsZero = errors .New ("gocron: WithLimitedRuns: limit must be greater than 0" )
6263)
6364
6465// internal errors
Original file line number Diff line number Diff line change @@ -643,6 +643,9 @@ func WithEventListeners(eventListeners ...EventListener) JobOption {
643643// Upon reaching the limit, the job is removed from the scheduler.
644644func WithLimitedRuns (limit uint ) JobOption {
645645 return func (j * internalJob , _ time.Time ) error {
646+ if limit == 0 {
647+ return ErrWithLimitedRunsZero
648+ }
646649 j .limitRunsTo = & limitRunsTo {
647650 limit : limit ,
648651 runCount : 0 ,
Original file line number Diff line number Diff line change @@ -1056,6 +1056,14 @@ func TestScheduler_NewJobErrors(t *testing.T) {
10561056 []JobOption {WithIdentifier (uuid .Nil )},
10571057 ErrWithIdentifierNil ,
10581058 },
1059+ {
1060+ "WithLimitedRuns is zero" ,
1061+ DurationJob (
1062+ time .Second ,
1063+ ),
1064+ []JobOption {WithLimitedRuns (0 )},
1065+ ErrWithLimitedRunsZero ,
1066+ },
10591067 }
10601068
10611069 for _ , tt := range tests {
You can’t perform that action at this time.
0 commit comments