func TestRecurringEnded(t *testing.T) { tk := tasks.NilTask() r := recurring.AtInterval(kNow, time.Hour) e := tasks.Start(tasks.RecurringTask(tk, r)) e.End() <-e.Done() }
func TestRecurringError(t *testing.T) { timeTask := &fakeTask{err: kSomeError} r := recurring.AtInterval(kNow, time.Hour) tasks.RunForTesting( tasks.RecurringTask(timeTask, r), &tasks.ClockForTesting{kNow}) verifyTimes( t, timeTask.timeStamps, kNow.Add(time.Hour)) }
func TestRecurringOverrun(t *testing.T) { timeTask := &fakeTask{runDuration: time.Hour} r := recurring.Until( recurring.AtInterval(kNow, time.Hour), kNow.Add(5*time.Hour)) tasks.RunForTesting( tasks.RecurringTask(timeTask, r), &tasks.ClockForTesting{kNow}) verifyTimes( t, timeTask.timeStamps, kNow.Add(time.Hour), kNow.Add(3*time.Hour)) }
func TestRecurringCloseStream(t *testing.T) { task := tasks.NilTask() r := &testForClose{} tasks.RunForTesting( tasks.RecurringTask(task, r), &tasks.ClockForTesting{kNow}) if !r.closeCalled { t.Error("Expected close to be called.") } }