We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4a0cf00 commit 91cb0b0Copy full SHA for 91cb0b0
pkg/tasker/tasker_test.go
@@ -200,3 +200,26 @@ func TestConcurrency(t *testing.T) {
200
}
201
})
202
203
+
204
+func TestStopTasker(t *testing.T) {
205
+ t.Run("Run", func(t *testing.T) {
206
+ taskr := New(Option{Verbose: true, Out: "../../test/tasker.out"})
207
208
+ var incr int
209
+ taskr.Task("* * * * * *", func(ctx context.Context) (int, error) {
210
+ incr++
211
+ return 0, nil
212
+ }, false)
213
214
+ go func() {
215
+ time.Sleep(2 * time.Second)
216
+ taskr.Stop()
217
+ }()
218
+ taskr.Run()
219
+ fmt.Println(incr)
220
221
+ if incr != 1 {
222
+ t.Errorf("the task should run 1x, not %dx", incr)
223
+ }
224
+ })
225
+}
0 commit comments