(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestClassifyScheduleFrequency(t *testing.T) { |
| 13 | tests := []struct { |
| 14 | name string |
| 15 | input string |
| 16 | expected string |
| 17 | }{ |
| 18 | // Friendly format — direct string matches |
| 19 | {name: "hourly keyword", input: "hourly", expected: "hourly"}, |
| 20 | {name: "every 1h", input: "every 1h", expected: "hourly"}, |
| 21 | {name: "every 1 hour", input: "every 1 hour", expected: "hourly"}, |
| 22 | {name: "every 1 hours", input: "every 1 hours", expected: "hourly"}, |
| 23 | {name: "every 3h", input: "every 3h", expected: "3-hourly"}, |
| 24 | {name: "every 3 hours", input: "every 3 hours", expected: "3-hourly"}, |
| 25 | {name: "daily keyword", input: "daily", expected: "daily"}, |
| 26 | {name: "weekly keyword", input: "weekly", expected: "weekly"}, |
| 27 | |
| 28 | // Case insensitive |
| 29 | {name: "DAILY upper", input: "DAILY", expected: "daily"}, |
| 30 | {name: "Weekly mixed", input: "Weekly", expected: "weekly"}, |
| 31 | |
| 32 | // FUZZY placeholders |
| 33 | {name: "fuzzy hourly/1", input: "FUZZY:HOURLY/1 * * *", expected: "hourly"}, |
| 34 | {name: "fuzzy hourly/3", input: "FUZZY:HOURLY/3 * * *", expected: "3-hourly"}, |
| 35 | {name: "fuzzy daily", input: "FUZZY:DAILY * * *", expected: "daily"}, |
| 36 | {name: "fuzzy daily around", input: "FUZZY:DAILY_AROUND:14:0 * * *", expected: "daily"}, |
| 37 | {name: "fuzzy weekly", input: "FUZZY:WEEKLY * * *", expected: "weekly"}, |
| 38 | {name: "fuzzy weekly with day", input: "FUZZY:WEEKLY:1 * * *", expected: "weekly"}, |
| 39 | |
| 40 | // Standard cron expressions — daily pattern |
| 41 | {name: "cron daily midnight", input: "0 0 * * *", expected: "daily"}, |
| 42 | {name: "cron daily 9am", input: "0 9 * * *", expected: "daily"}, |
| 43 | {name: "cron daily 14:30", input: "30 14 * * *", expected: "daily"}, |
| 44 | |
| 45 | // Standard cron — weekly pattern |
| 46 | {name: "cron weekly monday", input: "0 0 * * 1", expected: "weekly"}, |
| 47 | {name: "cron weekly friday", input: "30 9 * * 5", expected: "weekly"}, |
| 48 | |
| 49 | // Standard cron — hourly patterns |
| 50 | {name: "cron every 1 hour", input: "0 */1 * * *", expected: "hourly"}, |
| 51 | {name: "cron every 3 hours", input: "0 */3 * * *", expected: "3-hourly"}, |
| 52 | {name: "cron every 6 hours (custom)", input: "0 */6 * * *", expected: "custom"}, |
| 53 | |
| 54 | // Monthly cron pattern |
| 55 | {name: "cron monthly 1st", input: "0 0 1 * *", expected: "monthly"}, |
| 56 | {name: "cron monthly 15th", input: "0 9 15 * *", expected: "monthly"}, |
| 57 | |
| 58 | // Custom / unrecognised |
| 59 | {name: "cron every 2 days", input: "0 0 */2 * *", expected: "custom"}, |
| 60 | {name: "random cron", input: "15 10 * * 1-5", expected: "custom"}, |
| 61 | } |
| 62 | |
| 63 | for _, tt := range tests { |
| 64 | t.Run(tt.name, func(t *testing.T) { |
| 65 | got := classifyScheduleFrequency(tt.input) |
| 66 | assert.Equal(t, tt.expected, got, "classifyScheduleFrequency(%q)", tt.input) |
| 67 | }) |
| 68 | } |
| 69 | } |
nothing calls this directly
no test coverage detected