(t *testing.T)
| 185 | } |
| 186 | |
| 187 | func TestParseGitHubURL_FileURLs(t *testing.T) { |
| 188 | tests := []struct { |
| 189 | name string |
| 190 | url string |
| 191 | wantType GitHubURLType |
| 192 | wantOwner string |
| 193 | wantRepo string |
| 194 | wantRef string |
| 195 | wantPath string |
| 196 | wantErr bool |
| 197 | }{ |
| 198 | { |
| 199 | name: "Blob URL with main branch", |
| 200 | url: "https://github.com/github/gh-aw-trial/blob/main/workflows/release-issue-linker.md", |
| 201 | wantType: URLTypeBlob, |
| 202 | wantOwner: "github", |
| 203 | wantRepo: "gh-aw-trial", |
| 204 | wantRef: "main", |
| 205 | wantPath: "workflows/release-issue-linker.md", |
| 206 | wantErr: false, |
| 207 | }, |
| 208 | { |
| 209 | name: "Tree URL with develop branch", |
| 210 | url: "https://github.com/owner/repo/tree/develop/custom/path/workflow.md", |
| 211 | wantType: URLTypeTree, |
| 212 | wantOwner: "owner", |
| 213 | wantRepo: "repo", |
| 214 | wantRef: "develop", |
| 215 | wantPath: "custom/path/workflow.md", |
| 216 | wantErr: false, |
| 217 | }, |
| 218 | { |
| 219 | name: "Raw URL with version tag", |
| 220 | url: "https://github.com/owner/repo/raw/v2.0.0/workflows/helper.md", |
| 221 | wantType: URLTypeRaw, |
| 222 | wantOwner: "owner", |
| 223 | wantRepo: "repo", |
| 224 | wantRef: "v2.0.0", |
| 225 | wantPath: "workflows/helper.md", |
| 226 | wantErr: false, |
| 227 | }, |
| 228 | { |
| 229 | name: "Raw githubusercontent with refs/heads/branch", |
| 230 | url: "https://raw.githubusercontent.com/github/gh-aw/refs/heads/main/.github/workflows/shared/mcp/serena.md", |
| 231 | wantType: URLTypeRawContent, |
| 232 | wantOwner: "github", |
| 233 | wantRepo: "gh-aw", |
| 234 | wantRef: "main", |
| 235 | wantPath: ".github/workflows/shared/mcp/serena.md", |
| 236 | wantErr: false, |
| 237 | }, |
| 238 | { |
| 239 | name: "Raw githubusercontent with commit SHA", |
| 240 | url: "https://raw.githubusercontent.com/github/gh-aw/fc7992627494253a869e177e5d1985d25f3bb316/.github/workflows/shared/mcp/serena.md", |
| 241 | wantType: URLTypeRawContent, |
| 242 | wantOwner: "github", |
| 243 | wantRepo: "gh-aw", |
| 244 | wantRef: "fc7992627494253a869e177e5d1985d25f3bb316", |
nothing calls this directly
no test coverage detected