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

Function TestIsValidGitHubIdentifier

pkg/parser/github_urls_test.go:777–838  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

775}
776
777func TestIsValidGitHubIdentifier(t *testing.T) {
778 tests := []struct {
779 name string
780 input string
781 want bool
782 }{
783 {
784 name: "Valid simple name",
785 input: "owner",
786 want: true,
787 },
788 {
789 name: "Valid with hyphen",
790 input: "my-repo",
791 want: true,
792 },
793 {
794 name: "Valid with underscore",
795 input: "my_repo",
796 want: true,
797 },
798 {
799 name: "Valid with numbers",
800 input: "repo123",
801 want: true,
802 },
803 {
804 name: "Invalid - starts with hyphen",
805 input: "-repo",
806 want: false,
807 },
808 {
809 name: "Invalid - ends with hyphen",
810 input: "repo-",
811 want: false,
812 },
813 {
814 name: "Invalid - too long",
815 input: "this-is-a-very-long-repository-name-that-exceeds-the-limit",
816 want: false,
817 },
818 {
819 name: "Invalid - empty",
820 input: "",
821 want: false,
822 },
823 {
824 name: "Invalid - special characters",
825 input: "repo@name",
826 want: false,
827 },
828 }
829
830 for _, tt := range tests {
831 t.Run(tt.name, func(t *testing.T) {
832 got := IsValidGitHubIdentifier(tt.input)
833 if got != tt.want {
834 t.Errorf("IsValidGitHubIdentifier() = %v, want %v", got, tt.want)

Callers

nothing calls this directly

Calls 3

IsValidGitHubIdentifierFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected