Skip to content

Commit 7d80021

Browse files
committed
test(cron): adding test for IsRunning function
Adds a test to validate the IsRunning function
1 parent a1ce701 commit 7d80021

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

cron_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,25 @@ func wait(wg *sync.WaitGroup) chan bool {
687687
return ch
688688
}
689689

690+
func TestIsRunning(t *testing.T) {
691+
wg := &sync.WaitGroup{}
692+
wg.Add(1)
693+
cron := New()
694+
cron.AddFunc("* * * * * ?", func() { wg.Done() })
695+
696+
cron.Start()
697+
time.Sleep(1 * time.Second)
698+
if !cron.IsRunning() {
699+
t.Error("cron is reporting as not running when it should be running")
700+
}
701+
702+
cron.Stop()
703+
time.Sleep(1 * time.Second)
704+
if cron.IsRunning() {
705+
t.Error("cron is reporting as running when it should be not running")
706+
}
707+
}
708+
690709
func stop(cron *Cron) chan bool {
691710
ch := make(chan bool)
692711
go func() {

0 commit comments

Comments
 (0)