UNPKG

@villedemontreal/scripting

Version:
45 lines 1.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LoggerRecorder = void 0; exports.simulateSonarServerIsNotFound = simulateSonarServerIsNotFound; exports.simulateSonarProjectDoesNotYetExist = simulateSonarProjectDoesNotYetExist; exports.simulateSonarProjectAlreadyExists = simulateSonarProjectAlreadyExists; /* eslint-disable @typescript-eslint/ban-types */ const nock = require("nock"); function simulateSonarServerIsNotFound() { nock('https://example.com').head(RegExp('/sonar/{0,1}')).reply(404); } function simulateSonarServerIsOk() { nock('https://example.com').head(RegExp('/sonar/{0,1}')).reply(200); } function simulateSonarProjectDoesNotYetExist() { simulateSonarServerIsOk(); nock('https://example.com') .get('/sonar/api/project_branches/list') .query({ project: 'my-test-project-key' }) .reply(404); } function simulateSonarProjectAlreadyExists() { simulateSonarServerIsOk(); nock('https://example.com') .get('/sonar/api/project_branches/list') .query({ project: 'my-test-project-key' }) .reply(200); } class LoggerRecorder { constructor() { this.recordedLogs = ''; // eslint-disable-next-line @typescript-eslint/no-this-alias const that = this; this.logger = new Proxy({}, { get: (target, prop) => { return function () { // eslint-disable-next-line prefer-rest-params that.recordedLogs += `${prop.toString()}: ${arguments[0]}\n`; }; }, }); } } exports.LoggerRecorder = LoggerRecorder; //# sourceMappingURL=sonarTestUtils.js.map