-
Notifications
You must be signed in to change notification settings - Fork 2
/
schedule_test.go
49 lines (39 loc) · 1.12 KB
/
schedule_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package raiden_test
import (
"context"
"testing"
"time"
"github.com/go-co-op/gocron/v2"
"github.com/sev-2/raiden"
"github.com/stretchr/testify/assert"
)
type SampleJob struct {
raiden.JobBase
}
func (j *SampleJob) Name() string {
return "SampleJob"
}
func (j *SampleJob) Duration() raiden.JobDuration {
return gocron.DurationRandomJob(4*time.Minute, 6*time.Minute)
}
func TestScheduler_SetTracer(t *testing.T) {
conf := loadConfig()
ss, err := raiden.NewSchedulerServer(conf, gocron.WithLimitConcurrentJobs(2, gocron.LimitModeReschedule))
assert.NoError(t, err)
ss.SetTracer(nil)
}
func TestScheduler_RegisterJob(t *testing.T) {
conf := loadConfig()
ss, err := raiden.NewSchedulerServer(conf, gocron.WithLimitConcurrentJobs(2, gocron.LimitModeReschedule))
assert.NoError(t, err)
err1 := ss.RegisterJob(&SampleJob{})
assert.NoError(t, err1)
}
func TestScheduler_Start(t *testing.T) {
conf := loadConfig()
ss, err := raiden.NewSchedulerServer(conf, gocron.WithLimitConcurrentJobs(2, gocron.LimitModeReschedule))
assert.NoError(t, err)
ss.Start()
err1 := ss.Stop(context.Background())
assert.NoError(t, err1)
}