(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestParsePRURL(t *testing.T) { |
| 13 | tests := []struct { |
| 14 | name string |
| 15 | url string |
| 16 | wantOwner string |
| 17 | wantRepo string |
| 18 | wantPR int |
| 19 | wantErr bool |
| 20 | }{ |
| 21 | { |
| 22 | name: "valid GitHub PR URL", |
| 23 | url: "https://github.com/trial/repo/pull/234", |
| 24 | wantOwner: "trial", |
| 25 | wantRepo: "repo", |
| 26 | wantPR: 234, |
| 27 | wantErr: false, |
| 28 | }, |
| 29 | { |
| 30 | name: "valid GitHub PR URL with hyphenated repo name", |
| 31 | url: "https://github.com/PR-OWNER/PR-REPO/pull/456", |
| 32 | wantOwner: "PR-OWNER", |
| 33 | wantRepo: "PR-REPO", |
| 34 | wantPR: 456, |
| 35 | wantErr: false, |
| 36 | }, |
| 37 | { |
| 38 | name: "valid GitHub PR URL with underscores", |
| 39 | url: "https://github.com/test_owner/test_repo/pull/789", |
| 40 | wantOwner: "test_owner", |
| 41 | wantRepo: "test_repo", |
| 42 | wantPR: 789, |
| 43 | wantErr: false, |
| 44 | }, |
| 45 | { |
| 46 | name: "invalid URL format", |
| 47 | url: "not-a-url", |
| 48 | wantErr: true, |
| 49 | }, |
| 50 | { |
| 51 | name: "non-GitHub URL with valid path structure", |
| 52 | url: "https://gitlab.com/owner/repo/pull/123", |
| 53 | wantOwner: "owner", |
| 54 | wantRepo: "repo", |
| 55 | wantPR: 123, |
| 56 | wantErr: false, |
| 57 | }, |
| 58 | { |
| 59 | name: "invalid GitHub URL path - missing pull", |
| 60 | url: "https://github.com/owner/repo/123", |
| 61 | wantErr: true, |
| 62 | }, |
| 63 | { |
| 64 | name: "invalid GitHub URL path - wrong format", |
| 65 | url: "https://github.com/owner/repo/pulls/123", |
| 66 | wantErr: true, |
| 67 | }, |
| 68 | { |
| 69 | name: "invalid PR number", |
nothing calls this directly
no test coverage detected