- try to fix tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import * as path from 'path';
|
||||
import * as path from 'path'
|
||||
import * as process from 'process'
|
||||
import * as cp from 'child_process'
|
||||
|
||||
@@ -11,7 +11,7 @@ test('missing values should result in failure', () => {
|
||||
}
|
||||
try {
|
||||
cp.execSync(`node ${ip}`, options).toString()
|
||||
fail("Should not succeed, because values miss")
|
||||
fail('Should not succeed, because values miss')
|
||||
} catch (error) {
|
||||
console.log(`correctly failed due to: ${error}`)
|
||||
}
|
||||
@@ -24,11 +24,11 @@ test('missing values should result in failure', () => {
|
||||
process.env['INPUT_REPO'] = 'release-changelog-builder-action'
|
||||
process.env['INPUT_FROMTAG'] = 'v0.3.0'
|
||||
process.env['INPUT_TOTAG'] = 'v0.5.0'
|
||||
|
||||
|
||||
const ip = path.join(__dirname, '..', 'lib', 'main.js')
|
||||
const options: cp.ExecSyncOptions = {
|
||||
env: process.env
|
||||
}
|
||||
const result = cp.execSync(`node ${ip}`, options).toString()
|
||||
// should succeed
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
import { ReleaseNotes } from '../src/releaseNotes'
|
||||
import { resolveConfiguration } from '../src/utils';
|
||||
import { Octokit } from '@octokit/rest';
|
||||
import {ReleaseNotes} from '../src/releaseNotes'
|
||||
import {resolveConfiguration} from '../src/utils'
|
||||
import {Octokit} from '@octokit/rest'
|
||||
|
||||
jest.setTimeout(180000)
|
||||
|
||||
// load octokit instance
|
||||
const octokit = new Octokit({
|
||||
auth: `token ${process.env.GITHUB_TOKEN}`
|
||||
})
|
||||
|
||||
|
||||
it('Should have empty changelog (tags)', async () => {
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const configuration = resolveConfiguration('', 'configs/configuration.json')
|
||||
const releaseNotes = new ReleaseNotes(octokit, {
|
||||
owner: 'mikepenz',
|
||||
@@ -27,8 +26,6 @@ it('Should have empty changelog (tags)', async () => {
|
||||
})
|
||||
|
||||
it('Should match generated changelog (tags)', async () => {
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const configuration = resolveConfiguration('', 'configs/configuration.json')
|
||||
const releaseNotes = new ReleaseNotes(octokit, {
|
||||
owner: 'mikepenz',
|
||||
@@ -50,9 +47,10 @@ it('Should match generated changelog (tags)', async () => {
|
||||
})
|
||||
|
||||
it('Should match generated changelog (refs)', async () => {
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const configuration = resolveConfiguration('', 'configs_test/configuration_all_placeholders.json')
|
||||
const configuration = resolveConfiguration(
|
||||
'',
|
||||
'configs_test/configuration_all_placeholders.json'
|
||||
)
|
||||
const releaseNotes = new ReleaseNotes(octokit, {
|
||||
owner: 'mikepenz',
|
||||
repo: 'release-changelog-builder-action',
|
||||
@@ -81,9 +79,10 @@ nhoelzl
|
||||
})
|
||||
|
||||
it('Should match ordered ASC', async () => {
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const configuration = resolveConfiguration('', 'configs_test/configuration_asc.json')
|
||||
const configuration = resolveConfiguration(
|
||||
'',
|
||||
'configs_test/configuration_asc.json'
|
||||
)
|
||||
const releaseNotes = new ReleaseNotes(octokit, {
|
||||
owner: 'mikepenz',
|
||||
repo: 'release-changelog-builder-action',
|
||||
@@ -95,13 +94,16 @@ it('Should match ordered ASC', async () => {
|
||||
|
||||
const changeLog = await releaseNotes.pull()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`## 🚀 Features\n\n22\n24\n25\n26\n28\n\n## 🐛 Fixes\n\n23\n\n`)
|
||||
expect(changeLog).toStrictEqual(
|
||||
`## 🚀 Features\n\n22\n24\n25\n26\n28\n\n## 🐛 Fixes\n\n23\n\n`
|
||||
)
|
||||
})
|
||||
|
||||
it('Should match ordered DESC', async () => {
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const configuration = resolveConfiguration('', 'configs_test/configuration_desc.json')
|
||||
const configuration = resolveConfiguration(
|
||||
'',
|
||||
'configs_test/configuration_desc.json'
|
||||
)
|
||||
const releaseNotes = new ReleaseNotes(octokit, {
|
||||
owner: 'mikepenz',
|
||||
repo: 'release-changelog-builder-action',
|
||||
@@ -113,5 +115,7 @@ it('Should match ordered DESC', async () => {
|
||||
|
||||
const changeLog = await releaseNotes.pull()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`## 🚀 Features\n\n28\n26\n25\n24\n22\n\n## 🐛 Fixes\n\n23\n\n`)
|
||||
})
|
||||
expect(changeLog).toStrictEqual(
|
||||
`## 🚀 Features\n\n28\n26\n25\n24\n22\n\n## 🐛 Fixes\n\n23\n\n`
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { resolveConfiguration } from '../src/utils';
|
||||
import { ReleaseNotesBuilder } from '../src/releaseNotesBuilder';
|
||||
import {resolveConfiguration} from '../src/utils'
|
||||
import {ReleaseNotesBuilder} from '../src/releaseNotesBuilder'
|
||||
|
||||
jest.setTimeout(180000)
|
||||
|
||||
it('Should match generated changelog (unspecified fromTag)', async () => {
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const configuration = resolveConfiguration('', 'configs/configuration.json')
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null,
|
||||
@@ -28,8 +28,6 @@ it('Should match generated changelog (unspecified fromTag)', async () => {
|
||||
})
|
||||
|
||||
it('Should use empty placeholder', async () => {
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const configuration = resolveConfiguration('', 'configs/configuration.json')
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null,
|
||||
@@ -49,9 +47,10 @@ it('Should use empty placeholder', async () => {
|
||||
})
|
||||
|
||||
it('Should fill empty placeholders', async () => {
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const configuration = resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json')
|
||||
const configuration = resolveConfiguration(
|
||||
'',
|
||||
'configs_test/configuration_empty_all_placeholders.json'
|
||||
)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null,
|
||||
'.',
|
||||
@@ -66,13 +65,16 @@ it('Should fill empty placeholders', async () => {
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`mikepenz\nrelease-changelog-builder-action\nv0.0.2\nv0.0.3`)
|
||||
expect(changeLog).toStrictEqual(
|
||||
`mikepenz\nrelease-changelog-builder-action\nv0.0.2\nv0.0.3`
|
||||
)
|
||||
})
|
||||
|
||||
it('Should fill `template` placeholders', async () => {
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const configuration = resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json')
|
||||
const configuration = resolveConfiguration(
|
||||
'',
|
||||
'configs_test/configuration_empty_all_placeholders.json'
|
||||
)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null,
|
||||
'.',
|
||||
@@ -87,13 +89,16 @@ it('Should fill `template` placeholders', async () => {
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`## 🧪 Tests\n\n- [CI] Specify Test Case\n - PR: #10\n\n\n\n\nmikepenz\nrelease-changelog-builder-action\nv0.0.1\nv0.0.3\n1\n0\n0`)
|
||||
expect(changeLog).toStrictEqual(
|
||||
`## 🧪 Tests\n\n- [CI] Specify Test Case\n - PR: #10\n\n\n\n\nmikepenz\nrelease-changelog-builder-action\nv0.0.1\nv0.0.3\n1\n0\n0`
|
||||
)
|
||||
})
|
||||
|
||||
it('Should fill `template` placeholders, ignore', async () => {
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const configuration = resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json')
|
||||
const configuration = resolveConfiguration(
|
||||
'',
|
||||
'configs_test/configuration_empty_all_placeholders.json'
|
||||
)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null,
|
||||
'.',
|
||||
@@ -108,14 +113,16 @@ it('Should fill `template` placeholders, ignore', async () => {
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`## 🚀 Features\n\n- Enhance sorting by using proper semver\n - PR: #51\n\n## 🧪 Tests\n\n- Improve test cases\n - PR: #49\n\n\n- Bump @types/node from 14.11.8 to 14.11.10\n - PR: #47\n- Adjust code to move fromTag resolving to main.ts\n - PR: #48\n- dev -> main\n - PR: #52\n- Update package.json to updated description\n - PR: #53\n- dev -> main\n - PR: #54\n\n- New additional placeholders for \`template\` and \`empty_template\`\n - PR: #50\n\nmikepenz\nrelease-changelog-builder-action\nv0.9.1\nv0.9.5\n2\n5\n1`)
|
||||
expect(changeLog).toStrictEqual(
|
||||
`## 🚀 Features\n\n- Enhance sorting by using proper semver\n - PR: #51\n\n## 🧪 Tests\n\n- Improve test cases\n - PR: #49\n\n\n- Bump @types/node from 14.11.8 to 14.11.10\n - PR: #47\n- Adjust code to move fromTag resolving to main.ts\n - PR: #48\n- dev -> main\n - PR: #52\n- Update package.json to updated description\n - PR: #53\n- dev -> main\n - PR: #54\n\n- New additional placeholders for \`template\` and \`empty_template\`\n - PR: #50\n\nmikepenz\nrelease-changelog-builder-action\nv0.9.1\nv0.9.5\n2\n5\n1`
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
it('Uncategorized category', async () => {
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const configuration = resolveConfiguration('', 'configs_test/configuration_uncategorized_category.json')
|
||||
const configuration = resolveConfiguration(
|
||||
'',
|
||||
'configs_test/configuration_uncategorized_category.json'
|
||||
)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null,
|
||||
'.',
|
||||
@@ -130,5 +137,7 @@ it('Uncategorized category', async () => {
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`## 🚀 Features\n\n- Enhance sorting by using proper semver\n - PR: #51\n\n## 📦 Uncategorized\n\n- Bump @types/node from 14.11.8 to 14.11.10\n - PR: #47\n- Adjust code to move fromTag resolving to main.ts\n - PR: #48\n- Improve test cases\n - PR: #49\n- dev -> main\n - PR: #52\n- Update package.json to updated description\n - PR: #53\n- dev -> main\n - PR: #54\n\n\n\nUncategorized:\n- Bump @types/node from 14.11.8 to 14.11.10\n - PR: #47\n- Adjust code to move fromTag resolving to main.ts\n - PR: #48\n- Improve test cases\n - PR: #49\n- dev -> main\n - PR: #52\n- Update package.json to updated description\n - PR: #53\n- dev -> main\n - PR: #54\n\n\nIgnored:\n- New additional placeholders for \`template\` and \`empty_template\`\n - PR: #50\n\n\n6\n1`)
|
||||
})
|
||||
expect(changeLog).toStrictEqual(
|
||||
`## 🚀 Features\n\n- Enhance sorting by using proper semver\n - PR: #51\n\n## 📦 Uncategorized\n\n- Bump @types/node from 14.11.8 to 14.11.10\n - PR: #47\n- Adjust code to move fromTag resolving to main.ts\n - PR: #48\n- Improve test cases\n - PR: #49\n- dev -> main\n - PR: #52\n- Update package.json to updated description\n - PR: #53\n- dev -> main\n - PR: #54\n\n\n\nUncategorized:\n- Bump @types/node from 14.11.8 to 14.11.10\n - PR: #47\n- Adjust code to move fromTag resolving to main.ts\n - PR: #48\n- Improve test cases\n - PR: #49\n- dev -> main\n - PR: #52\n- Update package.json to updated description\n - PR: #53\n- dev -> main\n - PR: #54\n\n\nIgnored:\n- New additional placeholders for \`template\` and \`empty_template\`\n - PR: #50\n\n\n6\n1`
|
||||
)
|
||||
})
|
||||
|
||||
+67
-61
@@ -1,87 +1,93 @@
|
||||
import { resolveConfiguration } from '../src/utils';
|
||||
import { ReleaseNotesBuilder } from '../src/releaseNotesBuilder';
|
||||
import { TagInfo, sortTags } from '../src/tags';
|
||||
import {resolveConfiguration} from '../src/utils'
|
||||
import {ReleaseNotesBuilder} from '../src/releaseNotesBuilder'
|
||||
import {TagInfo, sortTags} from '../src/tags'
|
||||
|
||||
jest.setTimeout(180000)
|
||||
|
||||
it('Should order tags correctly using semver', async () => {
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const tags: TagInfo[] = [
|
||||
{ name: "2020.4.0", commit: "" },
|
||||
{ name: "2020.4.0-rc02", commit: "" },
|
||||
{ name: "2020.3.2", commit: "" },
|
||||
{ name: "v2020.3.1", commit: "" },
|
||||
{ name: "2020.3.1-rc03", commit: "" },
|
||||
{ name: "2020.3.1-rc01", commit: "" },
|
||||
{ name: "2020.3.1-b01", commit: "" },
|
||||
{ name: "v2020.3.0", commit: "" }
|
||||
{name: '2020.4.0', commit: ''},
|
||||
{name: '2020.4.0-rc02', commit: ''},
|
||||
{name: '2020.3.2', commit: ''},
|
||||
{name: 'v2020.3.1', commit: ''},
|
||||
{name: '2020.3.1-rc03', commit: ''},
|
||||
{name: '2020.3.1-rc01', commit: ''},
|
||||
{name: '2020.3.1-b01', commit: ''},
|
||||
{name: 'v2020.3.0', commit: ''}
|
||||
]
|
||||
|
||||
const tagResolver = {
|
||||
method: "semver"
|
||||
method: 'semver'
|
||||
}
|
||||
const sorted = sortTags(tags, tagResolver).map(function (tag) {
|
||||
return tag.name
|
||||
}).join(",")
|
||||
const sorted = sortTags(tags, tagResolver)
|
||||
.map(function (tag) {
|
||||
return tag.name
|
||||
})
|
||||
.join(',')
|
||||
|
||||
expect(sorted).toStrictEqual(`2020.4.0,2020.4.0-rc02,2020.3.2,v2020.3.1,2020.3.1-rc03,2020.3.1-rc01,2020.3.1-b01,v2020.3.0`)
|
||||
expect(sorted).toStrictEqual(
|
||||
`2020.4.0,2020.4.0-rc02,2020.3.2,v2020.3.1,2020.3.1-rc03,2020.3.1-rc01,2020.3.1-b01,v2020.3.0`
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
it('Should order tags correctly using semver', async () => {
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const tags: TagInfo[] = [
|
||||
{ name: "0.0.1", commit: "" },
|
||||
{ name: "0.0.1-rc01", commit: "" },
|
||||
{ name: "0.1.0", commit: "" },
|
||||
{ name: "0.1.0-b01", commit: "" },
|
||||
{ name: "1.0.0", commit: "" },
|
||||
{ name: "1.0.0-a01", commit: "" },
|
||||
{ name: "2.0.0", commit: "" },
|
||||
{ name: "10.0.0", commit: "" },
|
||||
{ name: "10.1.0", commit: "" },
|
||||
{ name: "10.1.0-2", commit: "" },
|
||||
{ name: "20.0.2", commit: "" },
|
||||
{ name: "100.0.0", commit: "" },
|
||||
{ name: "1000.0.0", commit: "" },
|
||||
{name: '0.0.1', commit: ''},
|
||||
{name: '0.0.1-rc01', commit: ''},
|
||||
{name: '0.1.0', commit: ''},
|
||||
{name: '0.1.0-b01', commit: ''},
|
||||
{name: '1.0.0', commit: ''},
|
||||
{name: '1.0.0-a01', commit: ''},
|
||||
{name: '2.0.0', commit: ''},
|
||||
{name: '10.0.0', commit: ''},
|
||||
{name: '10.1.0', commit: ''},
|
||||
{name: '10.1.0-2', commit: ''},
|
||||
{name: '20.0.2', commit: ''},
|
||||
{name: '100.0.0', commit: ''},
|
||||
{name: '1000.0.0', commit: ''}
|
||||
]
|
||||
|
||||
const tagResolver = {
|
||||
method: "non-existing-method"
|
||||
method: 'non-existing-method'
|
||||
}
|
||||
const sorted = sortTags(tags, tagResolver).map(function (tag) {
|
||||
return tag.name
|
||||
}).join(",")
|
||||
const sorted = sortTags(tags, tagResolver)
|
||||
.map(function (tag) {
|
||||
return tag.name
|
||||
})
|
||||
.join(',')
|
||||
|
||||
expect(sorted).toStrictEqual(`1000.0.0,100.0.0,20.0.2,10.1.0,10.1.0-2,10.0.0,2.0.0,1.0.0,1.0.0-a01,0.1.0,0.1.0-b01,0.0.1,0.0.1-rc01`)
|
||||
expect(sorted).toStrictEqual(
|
||||
`1000.0.0,100.0.0,20.0.2,10.1.0,10.1.0-2,10.0.0,2.0.0,1.0.0,1.0.0-a01,0.1.0,0.1.0-b01,0.0.1,0.0.1-rc01`
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
it('Should order tags alphabetical', async () => {
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const tags: TagInfo[] = [
|
||||
{ name: "0.0.1", commit: "" },
|
||||
{ name: "0.0.1-rc01", commit: "" },
|
||||
{ name: "0.1.0-b01", commit: "" },
|
||||
{ name: "1.0.0", commit: "" },
|
||||
{ name: "a", commit: "" },
|
||||
{ name: "1.0.0-a01", commit: "" },
|
||||
{ name: "2.0.0", commit: "" },
|
||||
{ name: "10.0.0", commit: "" },
|
||||
{ name: "v1", commit: "" },
|
||||
{ name: "10.1.0", commit: "" },
|
||||
{ name: "10.1.0-2", commit: "" },
|
||||
{ name: "20.0.2", commit: "" },
|
||||
{ name: "1000.0.0", commit: "" },
|
||||
{name: '0.0.1', commit: ''},
|
||||
{name: '0.0.1-rc01', commit: ''},
|
||||
{name: '0.1.0-b01', commit: ''},
|
||||
{name: '1.0.0', commit: ''},
|
||||
{name: 'a', commit: ''},
|
||||
{name: '1.0.0-a01', commit: ''},
|
||||
{name: '2.0.0', commit: ''},
|
||||
{name: '10.0.0', commit: ''},
|
||||
{name: 'v1', commit: ''},
|
||||
{name: '10.1.0', commit: ''},
|
||||
{name: '10.1.0-2', commit: ''},
|
||||
{name: '20.0.2', commit: ''},
|
||||
{name: '1000.0.0', commit: ''}
|
||||
]
|
||||
|
||||
const tagResolver = {
|
||||
method: "sort"
|
||||
method: 'sort'
|
||||
}
|
||||
const sorted = sortTags(tags, tagResolver).map(function (tag) {
|
||||
return tag.name
|
||||
}).join(",")
|
||||
const sorted = sortTags(tags, tagResolver)
|
||||
.map(function (tag) {
|
||||
return tag.name
|
||||
})
|
||||
.join(',')
|
||||
|
||||
expect(sorted).toStrictEqual(`a,20.0.2,2.0.0,1000.0.0,10.1.0,10.1.0-2,10.0.0,1.0.0,1.0.0-a01,v1,0.1.0-b01,0.0.1,0.0.1-rc01`)
|
||||
})
|
||||
expect(sorted).toStrictEqual(
|
||||
`a,20.0.2,2.0.0,1000.0.0,10.1.0,10.1.0-2,10.0.0,1.0.0,1.0.0-a01,v1,0.1.0-b01,0.0.1,0.0.1-rc01`
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user