From 1788e1367d80202c77a3458b95e58d1bb05a565e Mon Sep 17 00:00:00 2001
From: Maximilian Brandau <maximilian.brandau@gmail.com>
Date: Fri, 20 Aug 2021 15:08:31 +0200
Subject: [PATCH] test: add test for missing line of #11221 (#11353)

---
 .../gitlab/__snapshots__/index.spec.ts.snap    | 16 ++++++++++++++++
 lib/platform/gitlab/index.spec.ts              | 18 ++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap
index 5d4c684615..2a334d5263 100644
--- a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap
+++ b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap
@@ -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 [
diff --git a/lib/platform/gitlab/index.spec.ts b/lib/platform/gitlab/index.spec.ts
index 9a27a2399a..ba8effbea1 100644
--- a/lib/platform/gitlab/index.spec.ts
+++ b/lib/platform/gitlab/index.spec.ts
@@ -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,
@@ -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';
-- 
GitLab