(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestIsCronExpression(t *testing.T) { |
| 12 | tests := []struct { |
| 13 | name string |
| 14 | input string |
| 15 | expected bool |
| 16 | }{ |
| 17 | {"midnight daily", "0 0 * * *", true}, |
| 18 | {"every 15 minutes", "*/15 * * * *", true}, |
| 19 | {"weekdays at 2pm", "0 14 * * 1-5", true}, |
| 20 | {"monday at 6:30am", "30 6 * * 1", true}, |
| 21 | {"christmas noon", "0 12 25 12 *", true}, |
| 22 | {"natural language daily", "daily", false}, |
| 23 | {"natural language weekly", "weekly on monday", false}, |
| 24 | {"natural language interval", "every 10 minutes", false}, |
| 25 | {"too few fields", "0 0 * *", false}, |
| 26 | {"too many fields", "0 0 * * * *", false}, |
| 27 | {"extra tokens", "0 0 * * * extra", false}, |
| 28 | {"invalid expression", "invalid cron expression", false}, |
| 29 | {"empty string", "", false}, |
| 30 | } |
| 31 | |
| 32 | for _, tt := range tests { |
| 33 | t.Run(tt.name, func(t *testing.T) { |
| 34 | result := IsCronExpression(tt.input) |
| 35 | assert.Equal(t, tt.expected, result, "IsCronExpression(%q)", tt.input) |
| 36 | }) |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | func TestIsDailyCron(t *testing.T) { |
| 41 | tests := []struct { |
nothing calls this directly
no test coverage detected