(t *testing.T)
| 383 | } |
| 384 | |
| 385 | func TestGitLabSelfHosted(t *testing.T) { |
| 386 | t.Parallel() |
| 387 | |
| 388 | gp, err := gitprovider.New("gitlab", "https://gitlab.corp.com", nil) |
| 389 | require.NoError(t, err) |
| 390 | |
| 391 | t.Run("ParseRepositoryOriginMatches", func(t *testing.T) { |
| 392 | t.Parallel() |
| 393 | owner, repo, _, ok := gp.ParseRepositoryOrigin("https://gitlab.corp.com/org/repo.git") |
| 394 | assert.True(t, ok) |
| 395 | assert.Equal(t, "org", owner) |
| 396 | assert.Equal(t, "repo", repo) |
| 397 | }) |
| 398 | |
| 399 | t.Run("ParseRepositoryOriginRejectsGitLabCom", func(t *testing.T) { |
| 400 | t.Parallel() |
| 401 | _, _, _, ok := gp.ParseRepositoryOrigin("https://gitlab.com/org/repo.git") |
| 402 | assert.False(t, ok, "gitlab.com URL should not match self-hosted instance") |
| 403 | }) |
| 404 | |
| 405 | t.Run("ParsePullRequestURLMatches", func(t *testing.T) { |
| 406 | t.Parallel() |
| 407 | ref, ok := gp.ParsePullRequestURL("https://gitlab.corp.com/org/repo/-/merge_requests/1") |
| 408 | assert.True(t, ok) |
| 409 | assert.Equal(t, "org", ref.Owner) |
| 410 | assert.Equal(t, "repo", ref.Repo) |
| 411 | assert.Equal(t, 1, ref.Number) |
| 412 | }) |
| 413 | |
| 414 | t.Run("ParsePullRequestURLRejectsGitLabCom", func(t *testing.T) { |
| 415 | t.Parallel() |
| 416 | _, ok := gp.ParsePullRequestURL("https://gitlab.com/org/repo/-/merge_requests/1") |
| 417 | assert.False(t, ok, "gitlab.com MR URL should not match self-hosted instance") |
| 418 | }) |
| 419 | |
| 420 | t.Run("BuildPullRequestURL", func(t *testing.T) { |
| 421 | t.Parallel() |
| 422 | result := gp.BuildPullRequestURL(gitprovider.PRRef{Owner: "org", Repo: "repo", Number: 42}) |
| 423 | assert.Equal(t, "https://gitlab.corp.com/org/repo/-/merge_requests/42", result) |
| 424 | }) |
| 425 | } |
nothing calls this directly
no test coverage detected