Skip to content

Commit

Permalink
refactor(job): allow job to support returning error
Browse files Browse the repository at this point in the history
  • Loading branch information
flc1125 committed Oct 26, 2024
1 parent 6f11bbf commit 0b565f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions job.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ func (fn JobFunc) Run(ctx context.Context) error {
return fn(ctx)
}

// NoopJob is a job that does nothing.
// it is useful for testing and examples.
type NoopJob struct{}

func (NoopJob) Run(context.Context) error {
Expand Down
12 changes: 12 additions & 0 deletions job_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package cron

import (
"context"
"testing"

"github.com/stretchr/testify/assert"
)

func TestJob_NoopJob(t *testing.T) {
assert.NoError(t, NoopJob{}.Run(context.Background()))
}

0 comments on commit 0b565f7

Please sign in to comment.