(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestNextAllowedAutostart(t *testing.T) { |
| 13 | t.Parallel() |
| 14 | |
| 15 | t.Run("WhenScheduleOutOfSync", func(t *testing.T) { |
| 16 | t.Parallel() |
| 17 | |
| 18 | // 1st January 2024 is a Monday |
| 19 | at := time.Date(2024, time.January, 1, 10, 0, 0, 0, time.UTC) |
| 20 | // Monday-Friday 9:00AM UTC |
| 21 | sched := "CRON_TZ=UTC 00 09 * * 1-5" |
| 22 | // Only allow an autostart on mondays |
| 23 | opts := schedule.TemplateScheduleOptions{ |
| 24 | AutostartRequirement: schedule.TemplateAutostartRequirement{ |
| 25 | DaysOfWeek: 0b00000001, |
| 26 | }, |
| 27 | } |
| 28 | |
| 29 | // NextAutostart will return a non-allowed autostart time as |
| 30 | // our AutostartRequirement only allows Mondays but we expect |
| 31 | // this to return a Tuesday. |
| 32 | next, allowed := schedule.NextAutostart(at, sched, opts) |
| 33 | require.False(t, allowed) |
| 34 | require.Equal(t, time.Date(2024, time.January, 2, 9, 0, 0, 0, time.UTC), next) |
| 35 | |
| 36 | // NextAllowedAutostart should return the next allowed autostart time. |
| 37 | next, err := schedule.NextAllowedAutostart(at, sched, opts) |
| 38 | require.NoError(t, err) |
| 39 | require.Equal(t, time.Date(2024, time.January, 8, 9, 0, 0, 0, time.UTC), next) |
| 40 | }) |
| 41 | } |
nothing calls this directly
no test coverage detected