(t *testing.T)
| 110 | } |
| 111 | |
| 112 | func TestParseGitHubURL_PRURLs(t *testing.T) { |
| 113 | tests := []struct { |
| 114 | name string |
| 115 | url string |
| 116 | wantOwner string |
| 117 | wantRepo string |
| 118 | wantPR int64 |
| 119 | wantErr bool |
| 120 | }{ |
| 121 | { |
| 122 | name: "Valid PR URL", |
| 123 | url: "https://github.com/trial/repo/pull/234", |
| 124 | wantOwner: "trial", |
| 125 | wantRepo: "repo", |
| 126 | wantPR: 234, |
| 127 | wantErr: false, |
| 128 | }, |
| 129 | { |
| 130 | name: "PR URL with hyphenated repo name", |
| 131 | url: "https://github.com/PR-OWNER/PR-REPO/pull/456", |
| 132 | wantOwner: "PR-OWNER", |
| 133 | wantRepo: "PR-REPO", |
| 134 | wantPR: 456, |
| 135 | wantErr: false, |
| 136 | }, |
| 137 | { |
| 138 | name: "PR URL with underscores", |
| 139 | url: "https://github.com/test_owner/test_repo/pull/789", |
| 140 | wantOwner: "test_owner", |
| 141 | wantRepo: "test_repo", |
| 142 | wantPR: 789, |
| 143 | wantErr: false, |
| 144 | }, |
| 145 | { |
| 146 | name: "Invalid PR number", |
| 147 | url: "https://github.com/owner/repo/pull/abc", |
| 148 | wantErr: true, |
| 149 | }, |
| 150 | } |
| 151 | |
| 152 | for _, tt := range tests { |
| 153 | t.Run(tt.name, func(t *testing.T) { |
| 154 | components, err := ParseGitHubURL(tt.url) |
| 155 | |
| 156 | if tt.wantErr { |
| 157 | if err == nil { |
| 158 | t.Errorf("ParseGitHubURL() expected error but got none") |
| 159 | } |
| 160 | return |
| 161 | } |
| 162 | |
| 163 | if err != nil { |
| 164 | t.Errorf("ParseGitHubURL() unexpected error: %v", err) |
| 165 | return |
| 166 | } |
| 167 | |
| 168 | if components.Type != URLTypePullRequest { |
| 169 | t.Errorf("ParseGitHubURL() type = %v, want %v", components.Type, URLTypePullRequest) |
nothing calls this directly
no test coverage detected