From 053c9edf9bad54e41b36bed2349a1805c53717e7 Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Wed, 7 Feb 2018 20:55:10 -0500 Subject: [PATCH] test: add test to parse GitLab/Bitbucket URLs with groups --- test/get-git-auth-url.test.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/get-git-auth-url.test.js b/test/get-git-auth-url.test.js index 6c58939e..7f2775a7 100644 --- a/test/get-git-auth-url.test.js +++ b/test/get-git-auth-url.test.js @@ -29,6 +29,14 @@ test.serial( } ); +test.serial('Handle "https" URL with group and subgroup', t => { + t.is(getAuthUrl('https://host.com/group/subgroup/owner/repo.git'), 'https://host.com/group/subgroup/owner/repo.git'); +}); + +test.serial('Handle "git" URL with group and subgroup', t => { + t.is(getAuthUrl('git@host.com:group/subgroup/owner/repo.git'), 'git@host.com:group/subgroup/owner/repo.git'); +}); + test.serial('Return the "https" formatted URL if "gitCredentials" is defined and repositoryUrl is a "git" URL', t => { process.env.GIT_CREDENTIALS = 'user:pass'; t.is(getAuthUrl('git@host.com:owner/repo.git'), 'https://user:pass@host.com/owner/repo.git'); @@ -79,3 +87,19 @@ test.serial('Return the "https" formatted URL if "gitCredentials" is defined wit process.env.GITLAB_TOKEN = 'token'; t.is(getAuthUrl('git@host.com:owner/repo.git'), 'https://gitlab-ci-token:token@host.com/owner/repo.git'); }); + +test.serial('Handle "https" URL with group and subgroup, with "GIT_CREDENTIALS"', t => { + process.env.GIT_CREDENTIALS = 'user:pass'; + t.is( + getAuthUrl('https://host.com/group/subgroup/owner/repo.git'), + 'https://user:pass@host.com/group/subgroup/owner/repo.git' + ); +}); + +test.serial('Handle "git" URL with group and subgroup, with "GIT_CREDENTIALS', t => { + process.env.GIT_CREDENTIALS = 'user:pass'; + t.is( + getAuthUrl('git@host.com:group/subgroup/owner/repo.git'), + 'https://user:pass@host.com/group/subgroup/owner/repo.git' + ); +});