Exemple #1
0
func TestPreferredTimeInPast(t *testing.T) {
	job := model.Job{
		Interval:      time.Duration(3 * time.Hour),
		PreferredTime: model.ClockTime{Hour: 13, Minute: 55},
	}
	last := model.Backup{
		Start:  time.Date(2015, 10, 29, 13, 50, 0, 0, time.UTC),
		End:    time.Date(2015, 10, 29, 13, 52, 0, 0, time.UTC),
		Result: model.BackupCompleted,
	}
	next := scheduler.NextDateRelative(job, last, now)
	assert.Equal(t, next, now)
}
Exemple #2
0
func TestErroredRetryAtPreferredTime(t *testing.T) {
	job := model.Job{
		Interval:      time.Duration(3 * time.Hour),
		PreferredTime: model.ClockTime{Hour: 14},
	}
	last := model.Backup{
		Start:  time.Date(2015, 10, 29, 13, 50, 0, 0, time.UTC),
		End:    time.Date(2015, 10, 29, 13, 52, 0, 0, time.UTC),
		Result: model.BackupFailed,
	}
	next := scheduler.NextDateRelative(job, last, now)
	assert.Equal(t, next, time.Date(2015, 10, 29, 14, 0, 0, 0, time.UTC))
}
Exemple #3
0
func TestSimpleAddition(t *testing.T) {
	assert := assert.New(t)

	job := model.Job{
		Interval:      time.Duration(1 * time.Hour),
		PreferredTime: model.ClockTime{Hour: 2},
	}
	last := model.Backup{
		Start:  time.Date(2015, 10, 29, 13, 50, 0, 0, time.UTC),
		End:    time.Date(2015, 10, 29, 13, 52, 0, 0, time.UTC),
		Result: model.BackupCompleted,
	}
	next := scheduler.NextDateRelative(job, last, now)
	assert.Equal(next, time.Date(2015, 10, 29, 14, 50, 0, 0, time.UTC))
}