summaryrefslogtreecommitdiffstats
path: root/pkg/commands/hosting_service/hosting_service_test.go
diff options
context:
space:
mode:
authorTheBlob42 <hessenmobbel@web.de>2022-04-10 15:26:31 +0200
committerJesse Duffield <jessedduffield@gmail.com>2022-04-11 17:17:40 +1000
commitbcc04664982f78fe919654f06a348e1ac25e364a (patch)
tree1be1ae4e6b5ee99c778e19ce04cb45b1fa36aa0c /pkg/commands/hosting_service/hosting_service_test.go
parent58ed23a47adbc4e0cef119c0f32adceaef28ff48 (diff)
feat: pull request support for bitbucket server
Diffstat (limited to 'pkg/commands/hosting_service/hosting_service_test.go')
-rw-r--r--pkg/commands/hosting_service/hosting_service_test.go56
1 files changed, 55 insertions, 1 deletions
diff --git a/pkg/commands/hosting_service/hosting_service_test.go b/pkg/commands/hosting_service/hosting_service_test.go
index df326c4ba..0c926117d 100644
--- a/pkg/commands/hosting_service/hosting_service_test.go
+++ b/pkg/commands/hosting_service/hosting_service_test.go
@@ -154,6 +154,60 @@ func TestGetPullRequestURL(t *testing.T) {
},
},
{
+ testName: "Opens a link to new pull request on Bitbucket Server (SSH)",
+ from: "feature/new",
+ remoteUrl: "ssh://git@mycompany.bitbucket.com/myproject/myrepo.git",
+ configServiceDomains: map[string]string{
+ // valid configuration for a bitbucket server URL
+ "mycompany.bitbucket.com": "bitbucketServer:mycompany.bitbucket.com",
+ },
+ test: func(url string, err error) {
+ assert.NoError(t, err)
+ assert.Equal(t, "https://mycompany.bitbucket.com/projects/myproject/repos/myrepo/pull-requests?create&sourceBranch=feature%2Fnew", url)
+ },
+ },
+ {
+ testName: "Opens a link to new pull request on Bitbucket Server (SSH) with specific target",
+ from: "feature/new",
+ to: "dev",
+ remoteUrl: "ssh://git@mycompany.bitbucket.com/myproject/myrepo.git",
+ configServiceDomains: map[string]string{
+ // valid configuration for a bitbucket server URL
+ "mycompany.bitbucket.com": "bitbucketServer:mycompany.bitbucket.com",
+ },
+ test: func(url string, err error) {
+ assert.NoError(t, err)
+ assert.Equal(t, "https://mycompany.bitbucket.com/projects/myproject/repos/myrepo/pull-requests?create&targetBranch=dev&sourceBranch=feature%2Fnew", url)
+ },
+ },
+ {
+ testName: "Opens a link to new pull request on Bitbucket Server (HTTP)",
+ from: "feature/new",
+ remoteUrl: "https://mycompany.bitbucket.com/scm/myproject/myrepo.git",
+ configServiceDomains: map[string]string{
+ // valid configuration for a bitbucket server URL
+ "mycompany.bitbucket.com": "bitbucketServer:mycompany.bitbucket.com",
+ },
+ test: func(url string, err error) {
+ assert.NoError(t, err)
+ assert.Equal(t, "https://mycompany.bitbucket.com/projects/myproject/repos/myrepo/pull-requests?create&sourceBranch=feature%2Fnew", url)
+ },
+ },
+ {
+ testName: "Opens a link to new pull request on Bitbucket Server (HTTP) with specific target",
+ from: "feature/new",
+ to: "dev",
+ remoteUrl: "https://mycompany.bitbucket.com/scm/myproject/myrepo.git",
+ configServiceDomains: map[string]string{
+ // valid configuration for a bitbucket server URL
+ "mycompany.bitbucket.com": "bitbucketServer:mycompany.bitbucket.com",
+ },
+ test: func(url string, err error) {
+ assert.NoError(t, err)
+ assert.Equal(t, "https://mycompany.bitbucket.com/projects/myproject/repos/myrepo/pull-requests?create&targetBranch=dev&sourceBranch=feature%2Fnew", url)
+ },
+ },
+ {
testName: "Throws an error if git service is unsupported",
from: "feature/divide-operation",
remoteUrl: "git@something.com:peter/calculator.git",
@@ -199,7 +253,7 @@ func TestGetPullRequestURL(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, "https://bitbucket.org/johndoe/social_network/pull-requests/new?source=feature%2Fprofile-page&t=1", url)
},
- expectedLoggedErrors: []string{"Unknown git service type: 'noservice'. Expected one of github, bitbucket, gitlab, azuredevops"},
+ expectedLoggedErrors: []string{"Unknown git service type: 'noservice'. Expected one of github, bitbucket, gitlab, azuredevops, bitbucketServer"},
},
{
testName: "Escapes reserved URL characters in from branch name",