(t *testing.T)
| 668 | } |
| 669 | |
| 670 | func TestSanitizeName(t *testing.T) { |
| 671 | tests := []struct { |
| 672 | name string |
| 673 | input string |
| 674 | opts *SanitizeOptions |
| 675 | expected string |
| 676 | }{ |
| 677 | { |
| 678 | name: "nil options remove special chars", |
| 679 | input: "My Workflow@123", |
| 680 | opts: nil, |
| 681 | expected: "my-workflow123", |
| 682 | }, |
| 683 | { |
| 684 | name: "preserve dot and underscore", |
| 685 | input: "My.Workflow_Name", |
| 686 | opts: &SanitizeOptions{ |
| 687 | PreserveSpecialChars: []rune{'.', '_'}, |
| 688 | }, |
| 689 | expected: "my.workflow_name", |
| 690 | }, |
| 691 | { |
| 692 | name: "trim and default when empty", |
| 693 | input: "@@@", |
| 694 | opts: &SanitizeOptions{ |
| 695 | TrimHyphens: true, |
| 696 | DefaultValue: "default-name", |
| 697 | }, |
| 698 | expected: "default-name", |
| 699 | }, |
| 700 | } |
| 701 | |
| 702 | for _, tt := range tests { |
| 703 | t.Run(tt.name, func(t *testing.T) { |
| 704 | result := SanitizeName(tt.input, tt.opts) |
| 705 | assertSanitizeResultWithContext( |
| 706 | t, |
| 707 | "SanitizeName", |
| 708 | fmt.Sprintf("%q, opts=%+v", tt.input, tt.opts), |
| 709 | result, |
| 710 | tt.expected, |
| 711 | ) |
| 712 | }) |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | func TestBuildSanitizePreservePattern(t *testing.T) { |
| 717 | tests := []struct { |
nothing calls this directly
no test coverage detected