diff --git a/job.go b/job.go index 4b3c354..3344170 100644 --- a/job.go +++ b/job.go @@ -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 { diff --git a/job_test.go b/job_test.go new file mode 100644 index 0000000..bca1ed1 --- /dev/null +++ b/job_test.go @@ -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())) +}