MCPcopy Create free account
hub / github.com/github/gh-aw / TestBuildScheduleOptions

Function TestBuildScheduleOptions

pkg/cli/add_interactive_schedule_test.go:370–440  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

368}
369
370func TestBuildScheduleOptions(t *testing.T) {
371 t.Run("custom schedule puts custom first", func(t *testing.T) {
372 opts := buildScheduleOptions("15 10 * * 1-5", "custom")
373 require.NotEmpty(t, opts, "options should not be empty")
374 assert.Equal(t, "custom", opts[0].Value, "custom should be first option")
375 })
376
377 t.Run("daily schedule puts daily first", func(t *testing.T) {
378 opts := buildScheduleOptions("daily", "daily")
379 require.NotEmpty(t, opts, "options should not be empty")
380 assert.Equal(t, "daily", opts[0].Value, "daily should be first option")
381 })
382
383 t.Run("hourly schedule puts hourly first", func(t *testing.T) {
384 opts := buildScheduleOptions("every 1h", "hourly")
385 require.NotEmpty(t, opts, "options should not be empty")
386 assert.Equal(t, "hourly", opts[0].Value, "hourly should be first option")
387 })
388
389 t.Run("weekly schedule puts weekly first", func(t *testing.T) {
390 opts := buildScheduleOptions("weekly", "weekly")
391 require.NotEmpty(t, opts, "options should not be empty")
392 assert.Equal(t, "weekly", opts[0].Value, "weekly should be first option")
393 })
394
395 t.Run("3-hourly schedule puts 3-hourly first", func(t *testing.T) {
396 opts := buildScheduleOptions("every 3h", "3-hourly")
397 require.NotEmpty(t, opts, "options should not be empty")
398 assert.Equal(t, "3-hourly", opts[0].Value, "3-hourly should be first option")
399 })
400
401 t.Run("monthly schedule puts monthly first", func(t *testing.T) {
402 opts := buildScheduleOptions("0 0 1 * *", "monthly")
403 require.NotEmpty(t, opts, "options should not be empty")
404 assert.Equal(t, "monthly", opts[0].Value, "monthly should be first option")
405 })
406
407 t.Run("includes all standard frequencies", func(t *testing.T) {
408 opts := buildScheduleOptions("daily", "daily")
409 require.NotEmpty(t, opts, "options should not be empty")
410 values := make(map[string]struct{})
411 for _, o := range opts {
412 values[o.Value] = struct{}{}
413 }
414 assert.Contains(t, values, "hourly", "hourly should be included")
415 assert.Contains(t, values, "3-hourly", "3-hourly should be included")
416 assert.Contains(t, values, "daily", "daily should be included")
417 assert.Contains(t, values, "weekly", "weekly should be included")
418 assert.Contains(t, values, "monthly", "monthly should be included")
419 })
420
421 t.Run("custom schedule has no duplicate custom option", func(t *testing.T) {
422 opts := buildScheduleOptions("15 10 * * 1-5", "custom")
423 count := 0
424 for _, o := range opts {
425 if o.Value == "custom" {
426 count++
427 }

Callers

nothing calls this directly

Calls 2

buildScheduleOptionsFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected