MCPcopy Index your code
hub / github.com/coder/coder / Test_Weekly

Function Test_Weekly

coderd/schedule/cron/cron_test.go:12–163  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func Test_Weekly(t *testing.T) {
13 t.Parallel()
14 testCases := []struct {
15 name string
16 spec string
17 at time.Time
18 expectedNext time.Time
19 expectedMin time.Duration
20 expectedDaysOfWeek string
21 expectedError string
22 expectedCron string
23 expectedLocation *time.Location
24 expectedString string
25 expectedTime string
26 }{
27 {
28 name: "with timezone",
29 spec: "CRON_TZ=US/Central 30 9 * * 1-5",
30 at: time.Date(2022, 4, 1, 14, 29, 0, 0, time.UTC),
31 expectedNext: time.Date(2022, 4, 1, 14, 30, 0, 0, time.UTC),
32 expectedMin: 24 * time.Hour,
33 expectedDaysOfWeek: "Mon-Fri",
34 expectedError: "",
35 expectedCron: "30 9 * * 1-5",
36 expectedLocation: mustLocation(t, "US/Central"),
37 expectedString: "CRON_TZ=US/Central 30 9 * * 1-5",
38 expectedTime: "9:30AM",
39 },
40 {
41 name: "without timezone",
42 spec: "30 9 * * 1-5",
43 at: time.Date(2022, 4, 1, 9, 29, 0, 0, time.UTC),
44 expectedNext: time.Date(2022, 4, 1, 9, 30, 0, 0, time.UTC),
45 expectedMin: 24 * time.Hour,
46 expectedDaysOfWeek: "Mon-Fri",
47 expectedError: "",
48 expectedCron: "30 9 * * 1-5",
49 expectedLocation: time.UTC,
50 expectedString: "CRON_TZ=UTC 30 9 * * 1-5",
51 expectedTime: "9:30AM",
52 },
53 {
54 name: "24h format",
55 spec: "30 13 * * 1-5",
56 at: time.Date(2022, 4, 1, 13, 29, 0, 0, time.UTC),
57 expectedNext: time.Date(2022, 4, 1, 13, 30, 0, 0, time.UTC),
58 expectedMin: 24 * time.Hour,
59 expectedDaysOfWeek: "Mon-Fri",
60 expectedError: "",
61 expectedCron: "30 13 * * 1-5",
62 expectedLocation: time.UTC,
63 expectedString: "CRON_TZ=UTC 30 13 * * 1-5",
64 expectedTime: "1:30PM",
65 },
66 {
67 name: "convoluted with timezone",
68 spec: "CRON_TZ=US/Central */5 12-18 * * 1,3,6",
69 at: time.Date(2022, 4, 1, 14, 29, 0, 0, time.UTC),

Callers

nothing calls this directly

Calls 11

WeeklyFunction · 0.92
CronMethod · 0.80
LocationMethod · 0.80
MinMethod · 0.80
DaysOfWeekMethod · 0.80
mustLocationFunction · 0.70
RunMethod · 0.65
NextMethod · 0.65
EqualMethod · 0.45
StringMethod · 0.45
TimeMethod · 0.45

Tested by

no test coverage detected