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

Function TestSanitizeName

pkg/stringutil/sanitize_test.go:670–714  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

668}
669
670func 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
716func TestBuildSanitizePreservePattern(t *testing.T) {
717 tests := []struct {

Callers

nothing calls this directly

Calls 3

SanitizeNameFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected