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

Function TestParseCLISchedule

cli/schedule_internal_test.go:10–118  ·  view source on GitHub ↗

nolint:paralleltest // t.Setenv

(t *testing.T)

Source from the content-addressed store, hash-verified

8
9//nolint:paralleltest // t.Setenv
10func TestParseCLISchedule(t *testing.T) {
11 for _, testCase := range []struct {
12 name string
13 input []string
14 expectedSchedule string
15 expectedError string
16 tzEnv string
17 }{
18 {
19 name: "TimeAndDayOfWeekAndLocation",
20 input: []string{"09:00AM", "Sun-Sat", "America/Chicago"},
21 expectedSchedule: "CRON_TZ=America/Chicago 0 9 * * Sun-Sat",
22 tzEnv: "UTC",
23 },
24 {
25 name: "TimeOfDay24HourAndDayOfWeekAndLocation",
26 input: []string{"09:00", "Sun-Sat", "America/Chicago"},
27 expectedSchedule: "CRON_TZ=America/Chicago 0 9 * * Sun-Sat",
28 tzEnv: "UTC",
29 },
30 {
31 name: "TimeOfDay24HourAndDayOfWeekAndLocationButItsAllQuoted",
32 input: []string{"09:00 Sun-Sat America/Chicago"},
33 expectedSchedule: "CRON_TZ=America/Chicago 0 9 * * Sun-Sat",
34 tzEnv: "UTC",
35 },
36 {
37 name: "TimeOfDayOnly",
38 input: []string{"09:00AM"},
39 expectedSchedule: "CRON_TZ=America/Chicago 0 9 * * *",
40 tzEnv: "America/Chicago",
41 },
42 {
43 name: "Time24Military",
44 input: []string{"0900"},
45 expectedSchedule: "CRON_TZ=America/Chicago 0 9 * * *",
46 tzEnv: "America/Chicago",
47 },
48 {
49 name: "DayOfWeekAndTime",
50 input: []string{"09:00AM", "Sun-Sat"},
51 expectedSchedule: "CRON_TZ=America/Chicago 0 9 * * Sun-Sat",
52 tzEnv: "America/Chicago",
53 },
54 {
55 name: "TimeAndLocation",
56 input: []string{"09:00AM", "America/Chicago"},
57 expectedSchedule: "CRON_TZ=America/Chicago 0 9 * * *",
58 tzEnv: "UTC",
59 },
60 {
61 name: "LazyTime",
62 input: []string{"9am", "America/Chicago"},
63 expectedSchedule: "CRON_TZ=America/Chicago 0 9 * * *",
64 tzEnv: "UTC",
65 },
66 {
67 name: "ZeroPrefixedLazyTime",

Callers

nothing calls this directly

Calls 7

parseCLIScheduleFunction · 0.85
SetenvMethod · 0.80
NotEmptyMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected