From 03c9acad2650b8fb2b3e2c7eebda61ddb331ecf2 Mon Sep 17 00:00:00 2001 From: Mikael Elkiaer <2102306+MikaelElkiaer@users.noreply.github.com> Date: Sat, 15 Jan 2022 11:51:44 +0100 Subject: add tests specific for URL escaping in PRs --- pkg/commands/hosting_service/hosting_service_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'pkg/commands') diff --git a/pkg/commands/hosting_service/hosting_service_test.go b/pkg/commands/hosting_service/hosting_service_test.go index 8227e4f66..a94b2edb3 100644 --- a/pkg/commands/hosting_service/hosting_service_test.go +++ b/pkg/commands/hosting_service/hosting_service_test.go @@ -220,6 +220,26 @@ func TestGetPullRequestURL(t *testing.T) { }, expectedLoggedErrors: []string{"Unknown git service type: 'noservice'. Expected one of github, bitbucket, gitlab"}, }, + { + testName: "Escapes reserved URL characters in from branch name", + from: "feature/someIssue#123", + to: "master", + remoteUrl: "git@gitlab.com:me/public/repo-with-issues.git", + test: func(url string, err error) { + assert.NoError(t, err) + assert.Equal(t, "https://gitlab.com/me/public/repo-with-issues/merge_requests/new?merge_request[source_branch]=feature%2FsomeIssue%23123&merge_request[target_branch]=master", url) + }, + }, + { + testName: "Escapes reserved URL characters in to branch name", + from: "yolo", + to: "archive/never-ending-feature#666", + remoteUrl: "git@gitlab.com:me/public/repo-with-issues.git", + test: func(url string, err error) { + assert.NoError(t, err) + assert.Equal(t, "https://gitlab.com/me/public/repo-with-issues/merge_requests/new?merge_request[source_branch]=yolo&merge_request[target_branch]=archive%2Fnever-ending-feature%23666", url) + }, + }, } for _, s := range scenarios { -- cgit v1.2.3