- fix tests, require to call mergeConfiguration to apply defaults

This commit is contained in:
Mike Penz
2023-01-03 15:57:27 +00:00
committed by GitHub
parent 77b2076a3f
commit 96975870c4
2 changed files with 26 additions and 26 deletions
+11 -11
View File
@@ -1,5 +1,5 @@
import {ReleaseNotes} from '../src/releaseNotes' import {ReleaseNotes} from '../src/releaseNotes'
import {resolveConfiguration} from '../src/utils' import {mergeConfiguration, resolveConfiguration} from '../src/utils'
import {Octokit} from '@octokit/rest' import {Octokit} from '@octokit/rest'
jest.setTimeout(180000) jest.setTimeout(180000)
@@ -10,7 +10,7 @@ const octokit = new Octokit({
}) })
it('Should have empty changelog (tags)', async () => { it('Should have empty changelog (tags)', async () => {
const configuration = resolveConfiguration('', 'configs/configuration.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs/configuration.json'))
const releaseNotes = new ReleaseNotes(octokit, { const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz', owner: 'mikepenz',
repo: 'release-changelog-builder-action', repo: 'release-changelog-builder-action',
@@ -31,7 +31,7 @@ it('Should have empty changelog (tags)', async () => {
}) })
it('Should match generated changelog (tags)', async () => { it('Should match generated changelog (tags)', async () => {
const configuration = resolveConfiguration('', 'configs/configuration.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs/configuration.json'))
const releaseNotes = new ReleaseNotes(octokit, { const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz', owner: 'mikepenz',
repo: 'release-changelog-builder-action', repo: 'release-changelog-builder-action',
@@ -57,7 +57,7 @@ it('Should match generated changelog (tags)', async () => {
}) })
it('Should match generated changelog (refs)', async () => { it('Should match generated changelog (refs)', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_all_placeholders.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_all_placeholders.json'))
const releaseNotes = new ReleaseNotes(octokit, { const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz', owner: 'mikepenz',
repo: 'release-changelog-builder-action', repo: 'release-changelog-builder-action',
@@ -91,7 +91,7 @@ nhoelzl
}) })
it('Should match generated changelog and replace all occurrences (refs)', async () => { it('Should match generated changelog and replace all occurrences (refs)', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_replace_all_placeholders.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_replace_all_placeholders.json'))
const releaseNotes = new ReleaseNotes(octokit, { const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz', owner: 'mikepenz',
repo: 'release-changelog-builder-action', repo: 'release-changelog-builder-action',
@@ -127,7 +127,7 @@ nhoelzl
}) })
it('Should match ordered ASC', async () => { it('Should match ordered ASC', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_asc.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_asc.json'))
const releaseNotes = new ReleaseNotes(octokit, { const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz', owner: 'mikepenz',
repo: 'release-changelog-builder-action', repo: 'release-changelog-builder-action',
@@ -148,7 +148,7 @@ it('Should match ordered ASC', async () => {
}) })
it('Should match ordered DESC', async () => { it('Should match ordered DESC', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_desc.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_desc.json'))
const releaseNotes = new ReleaseNotes(octokit, { const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz', owner: 'mikepenz',
repo: 'release-changelog-builder-action', repo: 'release-changelog-builder-action',
@@ -169,7 +169,7 @@ it('Should match ordered DESC', async () => {
}) })
it('Should match ordered by title ASC', async () => { it('Should match ordered by title ASC', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_sort_title_asc.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_sort_title_asc.json'))
const releaseNotes = new ReleaseNotes(octokit, { const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz', owner: 'mikepenz',
repo: 'release-changelog-builder-action', repo: 'release-changelog-builder-action',
@@ -192,7 +192,7 @@ it('Should match ordered by title ASC', async () => {
}) })
it('Should match ordered by title DESC', async () => { it('Should match ordered by title DESC', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_sort_title_desc.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_sort_title_desc.json'))
const releaseNotes = new ReleaseNotes(octokit, { const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz', owner: 'mikepenz',
repo: 'release-changelog-builder-action', repo: 'release-changelog-builder-action',
@@ -215,7 +215,7 @@ it('Should match ordered by title DESC', async () => {
}) })
it('Should ignore PRs not merged into develop branch', async () => { it('Should ignore PRs not merged into develop branch', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_base_branches_develop.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_base_branches_develop.json'))
const releaseNotes = new ReleaseNotes(octokit, { const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz', owner: 'mikepenz',
repo: 'release-changelog-builder-action', repo: 'release-changelog-builder-action',
@@ -236,7 +236,7 @@ it('Should ignore PRs not merged into develop branch', async () => {
}) })
it('Should ignore PRs not merged into main branch', async () => { it('Should ignore PRs not merged into main branch', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_base_branches_main.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_base_branches_main.json'))
const releaseNotes = new ReleaseNotes(octokit, { const releaseNotes = new ReleaseNotes(octokit, {
owner: 'mikepenz', owner: 'mikepenz',
repo: 'release-changelog-builder-action', repo: 'release-changelog-builder-action',
+15 -15
View File
@@ -1,10 +1,10 @@
import {resolveConfiguration} from '../src/utils' import {mergeConfiguration, resolveConfiguration} from '../src/utils'
import {ReleaseNotesBuilder} from '../src/releaseNotesBuilder' import {ReleaseNotesBuilder} from '../src/releaseNotesBuilder'
jest.setTimeout(180000) jest.setTimeout(180000)
it('Should match generated changelog (unspecified fromTag)', async () => { it('Should match generated changelog (unspecified fromTag)', async () => {
const configuration = resolveConfiguration('', 'configs/configuration.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs/configuration.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null, null,
null, null,
@@ -34,7 +34,7 @@ it('Should match generated changelog (unspecified fromTag)', async () => {
}) })
it('Should match generated changelog (unspecified tags)', async () => { it('Should match generated changelog (unspecified tags)', async () => {
const configuration = resolveConfiguration('', 'configs/configuration.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs/configuration.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null, null,
null, null,
@@ -59,7 +59,7 @@ it('Should match generated changelog (unspecified tags)', async () => {
}) })
it('Should use empty placeholder', async () => { it('Should use empty placeholder', async () => {
const configuration = resolveConfiguration('', 'configs/configuration.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs/configuration.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null, null,
null, null,
@@ -84,7 +84,7 @@ it('Should use empty placeholder', async () => {
}) })
it('Should fill empty placeholders', async () => { it('Should fill empty placeholders', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null, null,
null, null,
@@ -111,7 +111,7 @@ it('Should fill empty placeholders', async () => {
}) })
it('Should fill `template` placeholders', async () => { it('Should fill `template` placeholders', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null, null,
null, null,
@@ -138,7 +138,7 @@ it('Should fill `template` placeholders', async () => {
}) })
it('Should fill `template` placeholders, ignore', async () => { it('Should fill `template` placeholders, ignore', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null, null,
null, null,
@@ -165,7 +165,7 @@ it('Should fill `template` placeholders, ignore', async () => {
}) })
it('Uncategorized category', async () => { it('Uncategorized category', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_uncategorized_category.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_uncategorized_category.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null, null,
null, null,
@@ -192,7 +192,7 @@ it('Uncategorized category', async () => {
}) })
it('Verify commit based changelog', async () => { it('Verify commit based changelog', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_commits.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_commits.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null, null,
null, null,
@@ -219,7 +219,7 @@ it('Verify commit based changelog', async () => {
}) })
it('Verify commit based changelog, with emoji categorisation', async () => { it('Verify commit based changelog, with emoji categorisation', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_commits_emoji.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_commits_emoji.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null, null,
null, null,
@@ -246,7 +246,7 @@ it('Verify commit based changelog, with emoji categorisation', async () => {
}) })
it('Verify default inclusion of open PRs', async () => { it('Verify default inclusion of open PRs', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_including_open.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_including_open.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null, // baseUrl null, // baseUrl
null, // token null, // token
@@ -273,7 +273,7 @@ it('Verify default inclusion of open PRs', async () => {
}) })
it('Verify custom categorisation of open PRs', async () => { it('Verify custom categorisation of open PRs', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_excluding_open.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_excluding_open.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null, // baseUrl null, // baseUrl
null, // token null, // token
@@ -300,7 +300,7 @@ it('Verify custom categorisation of open PRs', async () => {
}) })
it('Verify reviewers who approved are fetched and also release information', async () => { it('Verify reviewers who approved are fetched and also release information', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_approvers.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_approvers.json'))
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null, // baseUrl null, // baseUrl
null, // token null, // token
@@ -327,7 +327,7 @@ it('Verify reviewers who approved are fetched and also release information', asy
}) })
it('Fetch release information', async () => { it('Fetch release information', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_approvers.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_approvers.json'))
configuration.template = '${{FROM_TAG}}-${{FROM_TAG_DATE}}\n${{TO_TAG}}-${{TO_TAG_DATE}}\n${{DAYS_SINCE}}' configuration.template = '${{FROM_TAG}}-${{FROM_TAG_DATE}}\n${{TO_TAG}}-${{TO_TAG_DATE}}\n${{DAYS_SINCE}}'
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null, // baseUrl null, // baseUrl
@@ -353,7 +353,7 @@ it('Fetch release information', async () => {
}) })
it('Fetch release information for non existing tag / release', async () => { it('Fetch release information for non existing tag / release', async () => {
const configuration = resolveConfiguration('', 'configs_test/configuration_approvers.json') const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_approvers.json'))
configuration.template = '${{FROM_TAG}}-${{FROM_TAG_DATE}}\n${{TO_TAG}}-${{TO_TAG_DATE}}\n${{DAYS_SINCE}}' configuration.template = '${{FROM_TAG}}-${{FROM_TAG_DATE}}\n${{TO_TAG}}-${{TO_TAG_DATE}}\n${{DAYS_SINCE}}'
const releaseNotesBuilder = new ReleaseNotesBuilder( const releaseNotesBuilder = new ReleaseNotesBuilder(
null, // baseUrl null, // baseUrl