Skip to content

Commit

Permalink
[BUGFIX] Impossible de seeder en RA (PIX-15448)
Browse files Browse the repository at this point in the history
  • Loading branch information
pix-service-auto-merge authored Nov 26, 2024
2 parents 28d9e40 + f60462f commit 5d8b2d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 7 additions & 3 deletions api/db/database-builder/factory/learning-content/build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import nock from 'nock';

import { buildArea } from './build-area.js';
import { buildChallenge } from './build-challenge.js';
import { buildCompetence } from './build-competence.js';
Expand All @@ -11,6 +9,8 @@ import { buildThematic } from './build-thematic.js';
import { buildTube } from './build-tube.js';
import { buildTutorial } from './build-tutorial.js';

let nock;

export function build(learningContent) {
learningContent.frameworks?.forEach(buildFramework);
learningContent.areas?.forEach(buildArea);
Expand All @@ -23,8 +23,12 @@ export function build(learningContent) {
learningContent.tutorials?.forEach(buildTutorial);
learningContent.missions?.forEach(buildMission);

return nock('https://lcms-test.pix.fr/api')
return nock?.('https://lcms-test.pix.fr/api')
.get('/releases/latest')
.matchHeader('Authorization', 'Bearer test-api-key')
.reply(200, { content: learningContent });
}

export function injectNock(value) {
nock = value;
}
3 changes: 3 additions & 0 deletions api/tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const databaseBuilder = await DatabaseBuilder.create({
},
});

// TEMPORARY WORKAROUND
databaseBuilder.factory.learningContent.injectNock(nock);

nock.disableNetConnect();
nock.enableNetConnect('localhost:9090');
const EMPTY_BLANK_AND_NULL = ['', '\t \n', null];
Expand Down

0 comments on commit 5d8b2d4

Please sign in to comment.