示例#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()
}
示例#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))
}
示例#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))
}
示例#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.")
	}
}