(t *testing.T)
| 245 | } |
| 246 | |
| 247 | func TestGitHubBuildBranchURL(t *testing.T) { |
| 248 | t.Parallel() |
| 249 | gp, err := gitprovider.New("github", "", nil) |
| 250 | require.NoError(t, err) |
| 251 | require.NotNil(t, gp) |
| 252 | |
| 253 | tests := []struct { |
| 254 | name string |
| 255 | owner string |
| 256 | repo string |
| 257 | branch string |
| 258 | expected string |
| 259 | }{ |
| 260 | { |
| 261 | name: "Simple branch", |
| 262 | owner: "coder", |
| 263 | repo: "coder", |
| 264 | branch: "main", |
| 265 | expected: "https://github.com/coder/coder/tree/main", |
| 266 | }, |
| 267 | { |
| 268 | name: "Branch with slash", |
| 269 | owner: "coder", |
| 270 | repo: "coder", |
| 271 | branch: "feat/new-thing", |
| 272 | expected: "https://github.com/coder/coder/tree/feat/new-thing", |
| 273 | }, |
| 274 | { |
| 275 | name: "Empty owner", |
| 276 | owner: "", |
| 277 | repo: "coder", |
| 278 | branch: "main", |
| 279 | expected: "", |
| 280 | }, |
| 281 | { |
| 282 | name: "Empty repo", |
| 283 | owner: "coder", |
| 284 | repo: "", |
| 285 | branch: "main", |
| 286 | expected: "", |
| 287 | }, |
| 288 | { |
| 289 | name: "Empty branch", |
| 290 | owner: "coder", |
| 291 | repo: "coder", |
| 292 | branch: "", |
| 293 | expected: "", |
| 294 | }, |
| 295 | { |
| 296 | name: "Branch with slashes", |
| 297 | owner: "my-org", |
| 298 | repo: "my-repo", |
| 299 | branch: "feat/new-thing", |
| 300 | expected: "https://github.com/my-org/my-repo/tree/feat/new-thing", |
| 301 | }, |
| 302 | } |
| 303 | |
| 304 | for _, tt := range tests { |
nothing calls this directly
no test coverage detected