MCPcopy
hub / github.com/robfig/cron / TestNormalizeFields_Errors

Function TestNormalizeFields_Errors

parser_test.go:270–313  ·  parser_test.go::TestNormalizeFields_Errors
(t *testing.T)

Source from the content-addressed store, hash-verified

268}
269
270func TestNormalizeFields_Errors(t *testing.T) {
271 tests := []struct {
272 name string
273 input []string
274 options ParseOption
275 err string
276 }{
277 {
278 "TwoOptionals",
279 []string{"0", "5", "*", "*", "*", "*"},
280 SecondOptional | Minute | Hour | Dom | Month | DowOptional,
281 "",
282 },
283 {
284 "TooManyFields",
285 []string{"0", "5", "*", "*"},
286 SecondOptional | Minute | Hour,
287 "",
288 },
289 {
290 "NoFields",
291 []string{},
292 SecondOptional | Minute | Hour,
293 "",
294 },
295 {
296 "TooFewFields",
297 []string{"*"},
298 SecondOptional | Minute | Hour,
299 "",
300 },
301 }
302 for _, test := range tests {
303 t.Run(test.name, func(t *testing.T) {
304 actual, err := normalizeFields(test.input, test.options)
305 if err == nil {
306 t.Errorf("expected an error, got none. results: %v", actual)
307 }
308 if !strings.Contains(err.Error(), test.err) {
309 t.Errorf("expected error %q, got %q", test.err, err.Error())
310 }
311 })
312 }
313}
314
315func TestStandardSpecSchedule(t *testing.T) {
316 entries := []struct {

Callers

nothing calls this directly

Calls 3

normalizeFieldsFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected