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

Function TestScheduleFriendlyComments

pkg/workflow/schedule_preprocessing_test.go:578–617  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

576}
577
578func TestScheduleFriendlyComments(t *testing.T) {
579 // Create a test frontmatter with a fuzzy schedule that will have a friendly format
580 frontmatter := map[string]any{
581 "on": map[string]any{
582 "schedule": []any{
583 map[string]any{
584 "cron": "daily around 14:00",
585 },
586 },
587 },
588 }
589
590 compiler := NewCompiler()
591 compiler.SetWorkflowIdentifier("test-workflow.md")
592
593 // Preprocess to convert and store friendly formats
594 err := compiler.preprocessScheduleFields(frontmatter, "", "")
595 if err != nil {
596 t.Fatalf("preprocessing failed: %v", err)
597 }
598
599 // Create test YAML output
600 yamlStr := `"on":
601 schedule:
602 - cron: "30 13 * * *"
603 workflow_dispatch:`
604
605 // Add friendly comments
606 result := compiler.addFriendlyScheduleComments(yamlStr, frontmatter)
607
608 // Check that the comment was added
609 if !strings.Contains(result, "# Friendly format: daily around 14:00") {
610 t.Errorf("expected friendly format comment to be added, got:\n%s", result)
611 }
612
613 // Check that the cron expression is still there
614 if !strings.Contains(result, `cron: "30 13 * * *"`) {
615 t.Errorf("expected cron expression to remain, got:\n%s", result)
616 }
617}
618
619func TestFuzzyScheduleScattering(t *testing.T) {
620 tests := []struct {

Callers

nothing calls this directly

Calls 5

SetWorkflowIdentifierMethod · 0.95
NewCompilerFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected