Beispiel #1
0
// Test crontab removing the job after an error.
func TestCrontabError(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	// Create test crontab with job.
	c := timex.NewCrontab(10 * time.Millisecond)
	j := &cronjob{0, false, true}

	c.Add("remove", j)
	time.Sleep(250 * time.Millisecond)
	c.Remove("remove")
	c.Stop()

	assert.Equal(j.counter, 5, "job counter increased max five times")
}
Beispiel #2
0
// Test crontab keeping the job.
func TestCrontabKeep(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	// Create test crontab with job.
	c := timex.NewCrontab(10 * time.Millisecond)
	j := &cronjob{0, false, false}

	c.Add("keep", j)
	time.Sleep(50 * time.Millisecond)
	c.Remove("keep")
	c.Stop()

	assert.Equal(j.counter, 3, "job counter increased twice")
}