Skip to content

Commit

Permalink
test: add test for missing line of #11221 (#11353)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrandau committed Aug 20, 2021
1 parent b9d015f commit 1788e13
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/platform/gitlab/__snapshots__/index.spec.ts.snap
Expand Up @@ -2686,6 +2686,22 @@ Array [
]
`;

exports[`platform/gitlab/index initRepo should throw if ssh_url_to_repo is not present but gitUrl is set to ssh 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate, br",
"authorization": "Bearer abc123",
"host": "gitlab.com",
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://gitlab.com/api/v4/projects/some%2Frepo%2Fproject",
},
]
`;

exports[`platform/gitlab/index initRepo should fall back respecting when GITLAB_IGNORE_REPO_URL is set 1`] = `
Array [
Array [
Expand Down
18 changes: 18 additions & 0 deletions lib/platform/gitlab/index.spec.ts
Expand Up @@ -2,6 +2,7 @@
import { Platform, RepoParams } from '..';
import * as httpMock from '../../../test/http-mock';
import {
CONFIG_GIT_URL_UNAVAILABLE,
REPOSITORY_ARCHIVED,
REPOSITORY_CHANGED,
REPOSITORY_DISABLED,
Expand Down Expand Up @@ -302,6 +303,23 @@ describe('platform/gitlab/index', () => {
expect(git.initRepo.mock.calls).toMatchSnapshot();
});

it('should throw if ssh_url_to_repo is not present but gitUrl is set to ssh', async () => {
httpMock
.scope(gitlabApiHost)
.get('/api/v4/projects/some%2Frepo%2Fproject')
.reply(200, {
default_branch: 'master',
http_url_to_repo: `https://gitlab.com/some%2Frepo%2Fproject.git`,
});
await expect(
gitlab.initRepo({
repository: 'some/repo/project',
gitUrl: 'ssh',
})
).rejects.toThrow(CONFIG_GIT_URL_UNAVAILABLE);
expect(httpMock.getTrace()).toMatchSnapshot();
});

it('should fall back respecting when GITLAB_IGNORE_REPO_URL is set', async () => {
process.env.GITLAB_IGNORE_REPO_URL = 'true';
const selfHostedUrl = 'http://mycompany.com/gitlab';
Expand Down

0 comments on commit 1788e13

Please sign in to comment.