From 554c01097d7e5c8b9fb046fba6a9e8bf5996aa8f Mon Sep 17 00:00:00 2001
From: Pierre-Yves Bigourdan <10694593+PyvesB@users.noreply.github.com>
Date: Mon, 12 Jun 2023 01:41:39 +0200
Subject: [PATCH] Fix [CodeClimate] tests and examples (#9253)

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
---
 .../codeclimate-analysis.service.js           |  6 ++---
 .../codeclimate-analysis.tester.js            | 24 +++++++++----------
 .../codeclimate-coverage.tester.js            |  6 ++---
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/services/codeclimate/codeclimate-analysis.service.js b/services/codeclimate/codeclimate-analysis.service.js
index e76351b6fd..f6e5905566 100644
--- a/services/codeclimate/codeclimate-analysis.service.js
+++ b/services/codeclimate/codeclimate-analysis.service.js
@@ -100,8 +100,8 @@ export default class CodeclimateAnalysis extends BaseJsonService {
         ':format(maintainability|maintainability-percentage)/:user/:repo',
       namedParams: {
         format: 'maintainability',
-        user: 'angular',
-        repo: 'angular',
+        user: 'tensorflow',
+        repo: 'models',
       },
       staticPreview: this.render({
         variant: 'maintainability',
@@ -122,7 +122,7 @@ export default class CodeclimateAnalysis extends BaseJsonService {
     {
       title: 'Code Climate technical debt',
       pattern: 'tech-debt/:user/:repo',
-      namedParams: { user: 'angular', repo: 'angular' },
+      namedParams: { user: 'tensorflow', repo: 'models' },
       staticPreview: this.render({
         variant: 'tech-debt',
         techDebtPercentage: 3.0,
diff --git a/services/codeclimate/codeclimate-analysis.tester.js b/services/codeclimate/codeclimate-analysis.tester.js
index ea58bc765a..b52283f80c 100644
--- a/services/codeclimate/codeclimate-analysis.tester.js
+++ b/services/codeclimate/codeclimate-analysis.tester.js
@@ -6,41 +6,41 @@ export const t = await createServiceTester()
 // Examples for this service can be found through the explore page:
 // https://codeclimate.com/explore
 
-t.create('issues count').get('/issues/angular/angular.json').expectBadge({
+t.create('issues count').get('/issues/tensorflow/models.json').expectBadge({
   label: 'issues',
   message: Joi.number().integer().positive(),
 })
 
 t.create('technical debt percentage')
-  .get('/tech-debt/angular/angular.json')
+  .get('/tech-debt/tensorflow/models.json')
   .expectBadge({
     label: 'technical debt',
     message: isIntegerPercentage,
   })
 
 t.create('maintainability percentage')
-  .get('/maintainability-percentage/angular/angular.json')
+  .get('/maintainability-percentage/tensorflow/models.json')
   .expectBadge({
     label: 'maintainability',
     message: isIntegerPercentage,
   })
 
 t.create('maintainability letter')
-  .get('/maintainability/angular/angular.json')
+  .get('/maintainability/tensorflow/models.json')
   .expectBadge({
     label: 'maintainability',
     message: Joi.equal('A', 'B', 'C', 'D', 'E', 'F'),
   })
 
 t.create('issues when outer user repos query returns multiple items')
-  .get('/issues/angular/angular.json')
+  .get('/issues/tensorflow/models.json')
   .intercept(nock =>
     nock('https://api.codeclimate.com', { allowUnmocked: true })
-      .get('/v1/repos?github_slug=angular%2Fangular')
+      .get('/v1/repos?github_slug=tensorflow%2Fmodels')
       .reply(200, {
         data: [
           {
-            id: '54fd4e6b6956804a10003df4',
+            id: 'xxxxxxxxxxxx', // Fake repo id, which is expected to be ignored in favour of the one that does contain snapshot data.
             relationships: {
               latest_default_branch_snapshot: {
                 data: null,
@@ -51,11 +51,11 @@ t.create('issues when outer user repos query returns multiple items')
             },
           },
           {
-            id: '54fd4e6b6956804a10003df3',
+            id: '57e2efacc718d40058000c9b', // Real repo id for tensorflow/models. The test retrieves live data using the real snapshot id below.
             relationships: {
               latest_default_branch_snapshot: {
                 data: {
-                  id: '620e2b491b6a72000100ca1d',
+                  id: '64786eee4fedea000101580d',
                   type: 'snapshots',
                 },
               },
@@ -88,10 +88,10 @@ t.create('maintainability letter for repo without snapshots')
   })
 
 t.create('malformed response for outer user repos query')
-  .get('/maintainability/angular/angular.json')
+  .get('/maintainability/tensorflow/models.json')
   .intercept(nock =>
     nock('https://api.codeclimate.com')
-      .get('/v1/repos?github_slug=angular%2Fangular')
+      .get('/v1/repos?github_slug=tensorflow%2Fmodels')
       .reply(200, {
         data: [{}], // No relationships in the list of data elements.
       })
@@ -102,7 +102,7 @@ t.create('malformed response for outer user repos query')
   })
 
 t.create('malformed response for inner specific repo query')
-  .get('/maintainability/angular/angular.json')
+  .get('/maintainability/tensorflow/models.json')
   .intercept(nock =>
     nock('https://api.codeclimate.com', { allowUnmocked: true })
       .get(/\/v1\/repos\/[a-z0-9]+\/snapshots\/[a-z0-9]+/)
diff --git a/services/codeclimate/codeclimate-coverage.tester.js b/services/codeclimate/codeclimate-coverage.tester.js
index 4f5796613b..94e20d1176 100644
--- a/services/codeclimate/codeclimate-coverage.tester.js
+++ b/services/codeclimate/codeclimate-coverage.tester.js
@@ -28,7 +28,7 @@ t.create('test coverage when outer user repos query returns multiple items')
       .reply(200, {
         data: [
           {
-            id: '558479d6e30ba034120008a8',
+            id: 'xxxxxxxxxxxx', // Fake repo id, which is expected to be ignored in favour of the one that does contain snapshot data.
             relationships: {
               latest_default_branch_snapshot: {
                 data: null,
@@ -39,14 +39,14 @@ t.create('test coverage when outer user repos query returns multiple items')
             },
           },
           {
-            id: '558479d6e30ba034120008a9',
+            id: '558479d6e30ba034120008a9', // Real repo id for codeclimate/codeclimate. The test retrieves live data using the real test report id below.
             relationships: {
               latest_default_branch_snapshot: {
                 data: null,
               },
               latest_default_branch_test_report: {
                 data: {
-                  id: '62110434a7160b00010b4b59',
+                  id: '6463c8a3e3bc340001004bce',
                   type: 'test_reports',
                 },
               },
-- 
GitLab