(t *testing.T)
| 576 | } |
| 577 | |
| 578 | func 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 | |
| 619 | func TestFuzzyScheduleScattering(t *testing.T) { |
| 620 | tests := []struct { |
nothing calls this directly
no test coverage detected