Skip to content
Snippets Groups Projects
Commit 7c3b6f10 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

refactor: add release notes in one place

parent 934adfdf
No related branches found
No related tags found
No related merge requests found
const versioning = require('../../../versioning');
const { addReleaseNotes } = require('./release-notes');
const sourceGithub = require('./source-github');
......@@ -42,15 +41,14 @@ async function getChangeLogJSON(args) {
try {
const res = await sourceGithub.getChangeLogJSON({ ...args });
const output = await addReleaseNotes(res);
const cacheMinutes = 60;
await renovateCache.set(
cacheNamespace,
getCacheKey(args),
output,
res,
cacheMinutes
);
return output;
return res;
} catch (err) /* istanbul ignore next */ {
logger.error(
{ err, message: err.message, stack: err.stack },
......
......@@ -2,6 +2,7 @@ const URL = require('url');
const endpoints = require('../../../util/endpoints');
const versioning = require('../../../versioning');
const ghGot = require('../../../platform/github/gh-got-wrapper');
const { addReleaseNotes } = require('./release-notes');
module.exports = {
getChangeLogJSON,
......@@ -131,7 +132,7 @@ async function getChangeLogJSON({
}
}
const res = {
let res = {
project: {
githubBaseURL,
github: repository,
......@@ -140,6 +141,7 @@ async function getChangeLogJSON({
versions: changelogReleases,
};
logger.debug({ res }, 'Manual res');
res = await addReleaseNotes(res);
return res;
}
jest.mock('../../../lib/platform/github/gh-got-wrapper');
jest.mock('../../../lib/datasource/npm');
jest.mock('../../../../lib/platform/github/gh-got-wrapper');
jest.mock('../../../../lib/datasource/npm');
jest.mock('got');
const endpoints = require('../../../lib/util/endpoints');
const ghGot = require('../../../lib/platform/github/gh-got-wrapper');
const endpoints = require('../../../../lib/util/endpoints');
const ghGot = require('../../../../lib/platform/github/gh-got-wrapper');
const { getChangeLogJSON } = require('../../../lib/workers/pr/changelog');
const { getChangeLogJSON } = require('../../../../lib/workers/pr/changelog');
const releaseNotes = require('../../../../lib/workers/pr/changelog/release-notes');
releaseNotes.addReleaseNotes = jest.fn(input => input);
const upgrade = {
depName: 'renovate',
......
const fs = require('fs-extra');
const ghGot = require('gh-got');
const {
addReleaseNotes,
getReleaseNotes,
getReleaseNotesMd,
} = require('../../../lib/workers/pr/changelog/release-notes');
} = require('../../../../lib/workers/pr/changelog/release-notes');
const angularJsChangelogMd = fs.readFileSync(
'test/_fixtures/changelog-md/angular.js.md',
......@@ -28,6 +29,12 @@ const contentsResponse = [
jest.mock('gh-got');
describe('workers/pr/release-notes', () => {
describe('addReleaseNotes()', () => {
it('returns input if invalid', async () => {
const input = { a: 1 };
expect(await addReleaseNotes(input)).toEqual(input);
});
});
describe('getReleaseNotes()', () => {
it('gets release notes', async () => {
ghGot.mockReturnValueOnce({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment