Skip to content

Commit

Permalink
Return zero next schedule when no schedule
Browse files Browse the repository at this point in the history
This fixes test
  • Loading branch information
Victor Castell committed Mar 13, 2019
1 parent f6a5536 commit e35560d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions dkron/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,15 @@ func (j *Job) Unlock() error {

// GetNext returns the job's next schedule
func (j *Job) GetNext() (time.Time, error) {
s, err := cron.Parse(j.Schedule)
if err != nil {
return time.Time{}, err
if j.Schedule != "" {
s, err := cron.Parse(j.Schedule)
if err != nil {
return time.Time{}, err
}
return s.Next(time.Now()), nil
}
return s.Next(time.Now()), nil

return time.Time{}, nil
}

func (j *Job) isRunnable() bool {
Expand Down
2 changes: 1 addition & 1 deletion dkron/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestJobGetParent(t *testing.T) {

ptj, err := dependentTestJob.GetParent()
assert.NoError(t, err)
assert.Equal(t, parentTestJob, ptj)
assert.Equal(t, parentTestJob.Name, ptj.Name)

// Remove the parent job
dependentTestJob.ParentJob = ""
Expand Down

0 comments on commit e35560d

Please sign in to comment.