This commit is contained in:
DanB
2014-05-14 13:03:42 +02:00
2 changed files with 12 additions and 0 deletions

View File

@@ -55,6 +55,17 @@ func TestActionTimingOnlyHour(t *testing.T) {
}
}
func TestActionTimingHourYear(t *testing.T) {
at := &ActionTiming{Timing: &RateInterval{Timing: &RITiming{Years: utils.Years{2012}, StartTime: "10:01:00"}}}
st := at.GetNextStartTime(referenceDate)
_, m, d := now.Date()
expected := time.Date(2012, m, d, 10, 1, 0, 0, time.Local)
if !st.Equal(expected) {
t.Errorf("Expected %v was %v", expected, st)
}
}
func TestActionTimingOnlyWeekdays(t *testing.T) {
at := &ActionTiming{Timing: &RateInterval{Timing: &RITiming{WeekDays: []time.Weekday{time.Monday}}}}
st := at.GetNextStartTime(referenceDate)

View File

@@ -51,6 +51,7 @@ func (s *Scheduler) Loop() {
go a0.Execute()
// if after execute the next start time is in the past then
// do not add it to the queue
now = time.Now()
if !a0.GetNextStartTime(now).Before(now) {
s.queue = append(s.queue, a0)
s.queue = s.queue[1:]