Exemplo n.º 1
0
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()
}
Exemplo n.º 2
0
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))
}
Exemplo n.º 3
0
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))
}
Exemplo n.º 4
0
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.")
	}
}