(t *testing.T)
| 617 | } |
| 618 | |
| 619 | func TestFuzzyScheduleScattering(t *testing.T) { |
| 620 | tests := []struct { |
| 621 | name string |
| 622 | frontmatter map[string]any |
| 623 | workflowIdentifier string |
| 624 | checkScattered bool // If true, verify the result is scattered (not fuzzy) |
| 625 | expectError bool // If true, expect an error (fuzzy without identifier) |
| 626 | errorSubstring string |
| 627 | }{ |
| 628 | { |
| 629 | name: "fuzzy daily schedule with identifier", |
| 630 | frontmatter: map[string]any{ |
| 631 | "on": map[string]any{ |
| 632 | "schedule": []any{ |
| 633 | map[string]any{ |
| 634 | "cron": "daily", |
| 635 | }, |
| 636 | }, |
| 637 | }, |
| 638 | }, |
| 639 | workflowIdentifier: "workflow-a.md", |
| 640 | checkScattered: true, |
| 641 | expectError: false, |
| 642 | }, |
| 643 | { |
| 644 | name: "fuzzy daily schedule without identifier", |
| 645 | frontmatter: map[string]any{ |
| 646 | "on": map[string]any{ |
| 647 | "schedule": []any{ |
| 648 | map[string]any{ |
| 649 | "cron": "daily", |
| 650 | }, |
| 651 | }, |
| 652 | }, |
| 653 | }, |
| 654 | workflowIdentifier: "", // No identifier, should error |
| 655 | checkScattered: false, |
| 656 | expectError: true, |
| 657 | errorSubstring: "fuzzy cron expression", |
| 658 | }, |
| 659 | } |
| 660 | |
| 661 | for _, tt := range tests { |
| 662 | t.Run(tt.name, func(t *testing.T) { |
| 663 | compiler := NewCompiler() |
| 664 | if tt.workflowIdentifier != "" { |
| 665 | compiler.SetWorkflowIdentifier(tt.workflowIdentifier) |
| 666 | } |
| 667 | |
| 668 | err := compiler.preprocessScheduleFields(tt.frontmatter, "", "") |
| 669 | |
| 670 | if tt.expectError { |
| 671 | if err == nil { |
| 672 | t.Errorf("expected error containing '%s', got nil", tt.errorSubstring) |
| 673 | return |
| 674 | } |
| 675 | if !strings.Contains(err.Error(), tt.errorSubstring) { |
| 676 | t.Errorf("expected error containing '%s', got '%s'", tt.errorSubstring, err.Error()) |
nothing calls this directly
no test coverage detected