(t *testing.T)
| 119 | } |
| 120 | |
| 121 | func TestGitHubParsePullRequestURL(t *testing.T) { |
| 122 | t.Parallel() |
| 123 | gp, err := gitprovider.New("github", "", nil) |
| 124 | require.NoError(t, err) |
| 125 | require.NotNil(t, gp) |
| 126 | |
| 127 | tests := []struct { |
| 128 | name string |
| 129 | raw string |
| 130 | expectOK bool |
| 131 | expectOwner string |
| 132 | expectRepo string |
| 133 | expectNumber int |
| 134 | }{ |
| 135 | { |
| 136 | name: "Standard PR URL", |
| 137 | raw: "https://github.com/coder/coder/pull/123", |
| 138 | expectOK: true, |
| 139 | expectOwner: "coder", |
| 140 | expectRepo: "coder", |
| 141 | expectNumber: 123, |
| 142 | }, |
| 143 | { |
| 144 | name: "PR URL with query string", |
| 145 | raw: "https://github.com/coder/coder/pull/456?diff=split", |
| 146 | expectOK: true, |
| 147 | expectOwner: "coder", |
| 148 | expectRepo: "coder", |
| 149 | expectNumber: 456, |
| 150 | }, |
| 151 | { |
| 152 | name: "PR URL with fragment", |
| 153 | raw: "https://github.com/coder/coder/pull/789#discussion", |
| 154 | expectOK: true, |
| 155 | expectOwner: "coder", |
| 156 | expectRepo: "coder", |
| 157 | expectNumber: 789, |
| 158 | }, |
| 159 | { |
| 160 | name: "Not a PR URL", |
| 161 | raw: "https://github.com/coder/coder", |
| 162 | expectOK: false, |
| 163 | }, |
| 164 | { |
| 165 | name: "Issue URL (not PR)", |
| 166 | raw: "https://github.com/coder/coder/issues/123", |
| 167 | expectOK: false, |
| 168 | }, |
| 169 | { |
| 170 | name: "GitLab MR URL", |
| 171 | raw: "https://gitlab.com/coder/coder/-/merge_requests/123", |
| 172 | expectOK: false, |
| 173 | }, |
| 174 | { |
| 175 | name: "Empty string", |
| 176 | raw: "", |
| 177 | expectOK: false, |
| 178 | }, |
nothing calls this directly
no test coverage detected