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

Function TestParseGitHubURL_IssueURLs

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

Source from the content-addressed store, hash-verified

297}
298
299func TestParseGitHubURL_IssueURLs(t *testing.T) {
300 tests := []struct {
301 name string
302 url string
303 wantOwner string
304 wantRepo string
305 wantIssue int64
306 wantErr bool
307 }{
308 {
309 name: "Valid issue URL",
310 url: "https://github.com/owner/repo/issues/123",
311 wantOwner: "owner",
312 wantRepo: "repo",
313 wantIssue: 123,
314 wantErr: false,
315 },
316 {
317 name: "Invalid issue number",
318 url: "https://github.com/owner/repo/issues/abc",
319 wantErr: true,
320 },
321 }
322
323 for _, tt := range tests {
324 t.Run(tt.name, func(t *testing.T) {
325 components, err := ParseGitHubURL(tt.url)
326
327 if tt.wantErr {
328 if err == nil {
329 t.Errorf("ParseGitHubURL() expected error but got none")
330 }
331 return
332 }
333
334 if err != nil {
335 t.Errorf("ParseGitHubURL() unexpected error: %v", err)
336 return
337 }
338
339 if components.Type != URLTypeIssue {
340 t.Errorf("ParseGitHubURL() type = %v, want %v", components.Type, URLTypeIssue)
341 }
342
343 if components.Number != tt.wantIssue {
344 t.Errorf("ParseGitHubURL() issueNumber = %v, want %v", components.Number, tt.wantIssue)
345 }
346 })
347 }
348}
349
350func TestParseGitHubURL_Errors(t *testing.T) {
351 tests := []struct {

Callers

nothing calls this directly

Calls 3

ParseGitHubURLFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected