tests:add gitea test cases and fix tests error
This commit is contained in:
@@ -4,7 +4,7 @@ import {GithubRepository} from '../src/repositories/GithubRepository'
|
||||
|
||||
jest.setTimeout(180000)
|
||||
|
||||
const token = process.env.GITHUB_TOKEN || ""
|
||||
const token = process.env.GITHUB_TOKEN || ''
|
||||
const githubRepository = new GithubRepository(token, undefined, '.')
|
||||
it('[Github] Should match generated changelog (unspecified fromTag)', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs/configuration.json'))
|
||||
|
||||
@@ -0,0 +1,790 @@
|
||||
import {mergeConfiguration, resolveConfiguration} from '../src/utils'
|
||||
import {ReleaseNotesBuilder} from '../src/releaseNotesBuilder'
|
||||
import {GiteaRepository} from '../src/repositories/GiteaRepository'
|
||||
|
||||
jest.setTimeout(180000)
|
||||
|
||||
/**
|
||||
* Before starting testing, you should manually clone the repository
|
||||
* cd /tmp && git clone https://gitea.com/jolheiser/sip
|
||||
*/
|
||||
|
||||
const token = process.env.GITEA_TOKEN || ''
|
||||
const workingDirectory = '/tmp/sip/'
|
||||
const owner = 'jolheiser'
|
||||
const repo = 'sip'
|
||||
const configurationFile = 'configs/configuration_gitea.json'
|
||||
it('[Gitea] Should match generated changelog (unspecified fromTag)', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
|
||||
|
||||
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null,
|
||||
giteaRepository,
|
||||
workingDirectory,
|
||||
owner,
|
||||
repo,
|
||||
null,
|
||||
'v0.1.1',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true, // enable to fetch via commits
|
||||
false, // enable to fetch reviewers
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
null, // path to the cache
|
||||
configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`## 🧪 Upgrade
|
||||
|
||||
- Clean up and polish
|
||||
- PR: #1
|
||||
|
||||
`)
|
||||
})
|
||||
|
||||
//
|
||||
it('[Gitea] Should match generated changelog (unspecified tags)', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
|
||||
|
||||
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null,
|
||||
giteaRepository,
|
||||
workingDirectory,
|
||||
owner,
|
||||
repo,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false, // enable to fetch via commits
|
||||
false, // enable to fetch reviewers
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
null, // path to the cache
|
||||
configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`## 🚀 Features
|
||||
|
||||
- Add release attachments
|
||||
- PR: #26
|
||||
|
||||
`)
|
||||
})
|
||||
|
||||
it('[Gitea] Should use empty placeholder', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
|
||||
|
||||
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null,
|
||||
giteaRepository,
|
||||
workingDirectory,
|
||||
owner,
|
||||
repo,
|
||||
'v0.1.1',
|
||||
'v0.3.0',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true, // enable to fetch via commits
|
||||
false, // enable to fetch reviewers
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
null, // path to the cache
|
||||
configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`## 🚀 Features
|
||||
|
||||
- Add Drone and releases
|
||||
- PR: #2
|
||||
- Add search filters
|
||||
- PR: #8
|
||||
- Add qualifier module
|
||||
- PR: #10
|
||||
- Add create repo command
|
||||
- PR: #13
|
||||
- Add release support and CSV output
|
||||
- PR: #16
|
||||
|
||||
## 🐛 Fixes
|
||||
|
||||
- Fix PR head nil panic
|
||||
- PR: #7
|
||||
- Fix Drone release
|
||||
- PR: #14
|
||||
|
||||
`)
|
||||
})
|
||||
|
||||
it('[Gitea] Should fill empty placeholders', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json'))
|
||||
|
||||
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null,
|
||||
giteaRepository,
|
||||
workingDirectory,
|
||||
owner,
|
||||
repo,
|
||||
'v0.1.0',
|
||||
'v0.4.0',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true, // enable to fetch via commits
|
||||
false, // enable to fetch reviewers
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
null, // path to the cache
|
||||
configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(
|
||||
`## 🚀 Features
|
||||
|
||||
- Add create repo command
|
||||
- PR: #13
|
||||
- Add release support and CSV output
|
||||
- PR: #16
|
||||
- Add open functionality
|
||||
- PR: #21
|
||||
|
||||
## 📦 Uncategorized
|
||||
|
||||
- Clean up and polish
|
||||
- PR: #1
|
||||
- Add Drone and releases
|
||||
- PR: #2
|
||||
- Update Beaver and fix bugs
|
||||
- PR: #6
|
||||
- Fix PR head nil panic
|
||||
- PR: #7
|
||||
- Add search filters
|
||||
- PR: #8
|
||||
- Changelog 0.2.0
|
||||
- PR: #9
|
||||
- Add qualifier module
|
||||
- PR: #10
|
||||
- Fix Drone release
|
||||
- PR: #14
|
||||
- Imp formatting
|
||||
- PR: #17
|
||||
- Update Gitea SDK and other modules
|
||||
- PR: #19
|
||||
- Update modules
|
||||
- PR: #20
|
||||
- Add changelog for 0.3.0 and 0.4.0
|
||||
- PR: #22
|
||||
|
||||
|
||||
- Clean up and polish
|
||||
- PR: #1
|
||||
- Add Drone and releases
|
||||
- PR: #2
|
||||
- Update Beaver and fix bugs
|
||||
- PR: #6
|
||||
- Fix PR head nil panic
|
||||
- PR: #7
|
||||
- Add search filters
|
||||
- PR: #8
|
||||
- Changelog 0.2.0
|
||||
- PR: #9
|
||||
- Add qualifier module
|
||||
- PR: #10
|
||||
- Fix Drone release
|
||||
- PR: #14
|
||||
- Imp formatting
|
||||
- PR: #17
|
||||
- Update Gitea SDK and other modules
|
||||
- PR: #19
|
||||
- Update modules
|
||||
- PR: #20
|
||||
- Add changelog for 0.3.0 and 0.4.0
|
||||
- PR: #22
|
||||
|
||||
|
||||
jolheiser
|
||||
sip
|
||||
v0.1.0
|
||||
v0.4.0
|
||||
https://gitea.com/jolheiser/sip/compare/v0.1.0...v0.4.0
|
||||
3
|
||||
12
|
||||
0
|
||||
36
|
||||
1322
|
||||
274
|
||||
0
|
||||
16`
|
||||
)
|
||||
})
|
||||
|
||||
it('[Gitea] Should fill `template` placeholders', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json'))
|
||||
|
||||
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null,
|
||||
giteaRepository,
|
||||
workingDirectory,
|
||||
owner,
|
||||
repo,
|
||||
'v0.1.0',
|
||||
'v0.4.0',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true, // enable to fetch via commits
|
||||
false, // enable to fetch reviewers
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
null, // path to the cache
|
||||
configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(
|
||||
`## 🚀 Features
|
||||
|
||||
- Add create repo command
|
||||
- PR: #13
|
||||
- Add release support and CSV output
|
||||
- PR: #16
|
||||
- Add open functionality
|
||||
- PR: #21
|
||||
|
||||
## 📦 Uncategorized
|
||||
|
||||
- Clean up and polish
|
||||
- PR: #1
|
||||
- Add Drone and releases
|
||||
- PR: #2
|
||||
- Update Beaver and fix bugs
|
||||
- PR: #6
|
||||
- Fix PR head nil panic
|
||||
- PR: #7
|
||||
- Add search filters
|
||||
- PR: #8
|
||||
- Changelog 0.2.0
|
||||
- PR: #9
|
||||
- Add qualifier module
|
||||
- PR: #10
|
||||
- Fix Drone release
|
||||
- PR: #14
|
||||
- Imp formatting
|
||||
- PR: #17
|
||||
- Update Gitea SDK and other modules
|
||||
- PR: #19
|
||||
- Update modules
|
||||
- PR: #20
|
||||
- Add changelog for 0.3.0 and 0.4.0
|
||||
- PR: #22
|
||||
|
||||
|
||||
- Clean up and polish
|
||||
- PR: #1
|
||||
- Add Drone and releases
|
||||
- PR: #2
|
||||
- Update Beaver and fix bugs
|
||||
- PR: #6
|
||||
- Fix PR head nil panic
|
||||
- PR: #7
|
||||
- Add search filters
|
||||
- PR: #8
|
||||
- Changelog 0.2.0
|
||||
- PR: #9
|
||||
- Add qualifier module
|
||||
- PR: #10
|
||||
- Fix Drone release
|
||||
- PR: #14
|
||||
- Imp formatting
|
||||
- PR: #17
|
||||
- Update Gitea SDK and other modules
|
||||
- PR: #19
|
||||
- Update modules
|
||||
- PR: #20
|
||||
- Add changelog for 0.3.0 and 0.4.0
|
||||
- PR: #22
|
||||
|
||||
|
||||
jolheiser
|
||||
sip
|
||||
v0.1.0
|
||||
v0.4.0
|
||||
https://gitea.com/jolheiser/sip/compare/v0.1.0...v0.4.0
|
||||
3
|
||||
12
|
||||
0
|
||||
36
|
||||
1322
|
||||
274
|
||||
0
|
||||
16`
|
||||
)
|
||||
})
|
||||
|
||||
it('[Gitea] Should fill `template` placeholders, ignore', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json'))
|
||||
configuration.categories.pop() // drop `uncategorized` category
|
||||
|
||||
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null,
|
||||
giteaRepository,
|
||||
workingDirectory,
|
||||
owner,
|
||||
repo,
|
||||
'v0.3.0',
|
||||
'v0.5.0',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false, // enable to fetch via commits
|
||||
false, // enable to fetch reviewers
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
null, // path to the cache
|
||||
configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(
|
||||
`## 🚀 Features
|
||||
|
||||
- Add open functionality
|
||||
- PR: #21
|
||||
|
||||
|
||||
- Update modules
|
||||
- PR: #20
|
||||
- Add changelog for 0.3.0 and 0.4.0
|
||||
- PR: #22
|
||||
- Update Gitea SDK
|
||||
- PR: #23
|
||||
- Update repo info
|
||||
- PR: #24
|
||||
- Add release attachments
|
||||
- PR: #26
|
||||
- Refactor
|
||||
- PR: #29
|
||||
|
||||
|
||||
jolheiser
|
||||
sip
|
||||
v0.3.0
|
||||
v0.5.0
|
||||
https://gitea.com/jolheiser/sip/compare/v0.3.0...v0.5.0
|
||||
1
|
||||
6
|
||||
0
|
||||
41
|
||||
748
|
||||
314
|
||||
0
|
||||
8`
|
||||
)
|
||||
})
|
||||
|
||||
it('[Gitea] Uncategorized category', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_uncategorized_category.json'))
|
||||
|
||||
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null,
|
||||
giteaRepository,
|
||||
workingDirectory,
|
||||
owner,
|
||||
repo,
|
||||
'v0.3.0',
|
||||
'v0.5.0',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false, // enable to fetch via commits
|
||||
false, // enable to fetch reviewers
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
null, // path to the cache
|
||||
configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(
|
||||
`## 🚀 Features
|
||||
|
||||
- Add open functionality
|
||||
- PR: #21
|
||||
|
||||
## 📦 Uncategorized
|
||||
|
||||
- Update modules
|
||||
- PR: #20
|
||||
- Add changelog for 0.3.0 and 0.4.0
|
||||
- PR: #22
|
||||
- Update Gitea SDK
|
||||
- PR: #23
|
||||
- Update repo info
|
||||
- PR: #24
|
||||
- Add release attachments
|
||||
- PR: #26
|
||||
- Refactor
|
||||
- PR: #29
|
||||
|
||||
|
||||
|
||||
Uncategorized:
|
||||
- Update modules
|
||||
- PR: #20
|
||||
- Add changelog for 0.3.0 and 0.4.0
|
||||
- PR: #22
|
||||
- Update Gitea SDK
|
||||
- PR: #23
|
||||
- Update repo info
|
||||
- PR: #24
|
||||
- Add release attachments
|
||||
- PR: #26
|
||||
- Refactor
|
||||
- PR: #29
|
||||
|
||||
|
||||
Ignored:
|
||||
|
||||
|
||||
6
|
||||
0`
|
||||
)
|
||||
})
|
||||
|
||||
it('[Gitea] Verify commit based changelog', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_commits.json'))
|
||||
|
||||
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null,
|
||||
giteaRepository,
|
||||
workingDirectory,
|
||||
owner,
|
||||
repo,
|
||||
'v0.3.0',
|
||||
'v0.5.0',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true, // enable to fetch via commits
|
||||
false, // enable to fetch reviewers
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
true, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
null, // path to the cache
|
||||
configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(
|
||||
`## 📦 Uncategorized
|
||||
|
||||
- Update modules (#20)
|
||||
|
||||
- Add open functionality (#21)
|
||||
|
||||
- Add changelog for 0.3.0 and 0.4.0 (#22)
|
||||
|
||||
- Update Gitea SDK (#23)
|
||||
|
||||
- Update repo info (#24)
|
||||
|
||||
- Add release attachments (#26)
|
||||
|
||||
- Refactor (#29)
|
||||
|
||||
- Changelog 0.5.0 (#30)
|
||||
|
||||
|
||||
|
||||
|
||||
Uncategorized:
|
||||
- Update modules (#20)
|
||||
|
||||
- Add open functionality (#21)
|
||||
|
||||
- Add changelog for 0.3.0 and 0.4.0 (#22)
|
||||
|
||||
- Update Gitea SDK (#23)
|
||||
|
||||
- Update repo info (#24)
|
||||
|
||||
- Add release attachments (#26)
|
||||
|
||||
- Refactor (#29)
|
||||
|
||||
- Changelog 0.5.0 (#30)
|
||||
|
||||
|
||||
|
||||
Ignored:
|
||||
|
||||
|
||||
8
|
||||
0`
|
||||
)
|
||||
})
|
||||
|
||||
it('[Gitea] Verify commit based changelog', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
|
||||
|
||||
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null,
|
||||
giteaRepository,
|
||||
workingDirectory,
|
||||
owner,
|
||||
repo,
|
||||
'3e49adf6047960a03f53346bbececb3ce7e0809b',
|
||||
'894a641ef86c444dccfa55eca457186b5e10da95',
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false, // enable to fetch via commits
|
||||
false, // enable to fetch reviewers
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
true, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
null, // path to the cache
|
||||
configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(
|
||||
`## 🚀 Features
|
||||
|
||||
- Add release attachments (#26)
|
||||
- PR: #0
|
||||
|
||||
`
|
||||
)
|
||||
})
|
||||
// no open prs
|
||||
it('[Gitea] Verify default inclusion of open PRs', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_including_open.json'))
|
||||
|
||||
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null, // baseUrl
|
||||
giteaRepository, // token
|
||||
workingDirectory, // repoPath
|
||||
owner, // user
|
||||
repo, // repo
|
||||
'v0.5.0', // fromTag
|
||||
'master', // toTag
|
||||
true, // includeOpen
|
||||
false, // failOnError
|
||||
false, // ignorePrePrelease
|
||||
false, // enable to fetch via commits
|
||||
false, // enable to fetch reviewers
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
null, // path to the cache
|
||||
configuration // configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`
|
||||
|
||||
|
||||
Uncategorized
|
||||
- Add attachment removal and change message (#36) merged
|
||||
- Change to vanity URL (#37) merged
|
||||
|
||||
|
||||
|
||||
Open
|
||||
`)
|
||||
})
|
||||
|
||||
it('[Gitea] Verify custom categorisation of open PRs', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_excluding_open.json'))
|
||||
|
||||
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null, // baseUrl
|
||||
giteaRepository, // token
|
||||
workingDirectory, // repoPath
|
||||
owner, // user
|
||||
repo, // repo
|
||||
'v0.5.0', // fromTag
|
||||
'master', // toTag
|
||||
true, // includeOpen
|
||||
false, // failOnError
|
||||
false, // ignorePrePrelease
|
||||
false, // enable to fetch via commits
|
||||
false, // enable to fetch reviewers
|
||||
false, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
null, // path to the cache
|
||||
configuration // configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(``)
|
||||
})
|
||||
|
||||
it('[Gitea] Verify reviewers who approved are fetched and also release information', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_approvers.json'))
|
||||
|
||||
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null, // baseUrl
|
||||
giteaRepository, // token
|
||||
workingDirectory, // repoPath
|
||||
owner, // user
|
||||
repo, // repo
|
||||
'v0.5.0', // fromTag
|
||||
'master', // toTag
|
||||
true, // includeOpen
|
||||
false, // failOnError
|
||||
false, // ignorePrePrelease
|
||||
false, // enable to fetch via commits
|
||||
true, // enable to fetch reviewers
|
||||
true, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
null, // path to the cache
|
||||
configuration // configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(
|
||||
`## 📦 Uncategorized
|
||||
|
||||
- Add attachment removal and change message -- (#36) [merged] ---
|
||||
- Change to vanity URL -- (#37) [merged] ---
|
||||
|
||||
|
||||
|
||||
4`
|
||||
)
|
||||
})
|
||||
|
||||
it('[Gitea] Fetch release information', async () => {
|
||||
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}}'
|
||||
|
||||
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null, // baseUrl
|
||||
giteaRepository, // token
|
||||
workingDirectory, // repoPath
|
||||
owner, // user
|
||||
repo, // repo
|
||||
'v0.5.0', // fromTag
|
||||
'master', // toTag
|
||||
true, // includeOpen
|
||||
false, // failOnError
|
||||
false, // ignorePrePrelease
|
||||
false, // enable to fetch via commits
|
||||
false, // enable to fetch reviewers
|
||||
true, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
null, // path to the cache
|
||||
configuration // configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`v0.5.0-2020-09-17T16:34:40.000Z
|
||||
master-2020-09-21T19:30:21.000Z
|
||||
4`)
|
||||
})
|
||||
|
||||
it('[Gitea] Fetch release information for non existing tag / release', async () => {
|
||||
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}}'
|
||||
|
||||
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
|
||||
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||
null, // baseUrl
|
||||
giteaRepository, // token
|
||||
workingDirectory, // repoPath
|
||||
owner, // user
|
||||
repo, // repo
|
||||
'v0.5.0', // fromTag
|
||||
'master', // toTag
|
||||
true, // includeOpen
|
||||
false, // failOnError
|
||||
false, // ignorePrePrelease
|
||||
false, // enable to fetch via commits
|
||||
false, // enable to fetch reviewers
|
||||
true, // enable to fetch tag release information
|
||||
false, // enable to fetch reviews
|
||||
false, // enable commitMode
|
||||
false, // enable exportCache
|
||||
false, // enable exportOnly
|
||||
null, // path to the cache
|
||||
configuration // configuration
|
||||
)
|
||||
|
||||
const changeLog = await releaseNotesBuilder.build()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`v0.5.0-2020-09-17T16:34:40.000Z
|
||||
master-2020-09-21T19:30:21.000Z
|
||||
4`)
|
||||
})
|
||||
@@ -1,17 +1,14 @@
|
||||
import {checkExportedData, mergeConfiguration, resolveConfiguration} from '../src/utils'
|
||||
import {Octokit} from '@octokit/rest'
|
||||
import {buildChangelog} from '../src/transform'
|
||||
import {pullData} from '../src/pr-collector/prCollector'
|
||||
import {Data} from '../src/releaseNotesBuilder'
|
||||
import {GithubRepository} from "../src/repositories/GithubRepository";
|
||||
import {GithubRepository} from '../src/repositories/GithubRepository'
|
||||
|
||||
jest.setTimeout(180000)
|
||||
|
||||
// load octokit instance
|
||||
const enablePullData = false // if false -> use cache for data
|
||||
|
||||
|
||||
const token = process.env.GITHUB_TOKEN || ""
|
||||
const token = process.env.GITHUB_TOKEN || ''
|
||||
const githubRepository = new GithubRepository(token, undefined, '.')
|
||||
it('Should have empty changelog (tags)', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs/configuration.json'))
|
||||
@@ -28,7 +25,8 @@ it('Should have empty changelog (tags)', async () => {
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration
|
||||
configuration,
|
||||
repositoryUtils: githubRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
@@ -55,7 +53,8 @@ it('Should match generated changelog (tags)', async () => {
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration
|
||||
configuration,
|
||||
repositoryUtils: githubRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
@@ -88,7 +87,8 @@ it('Should match generated changelog (refs)', async () => {
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration
|
||||
configuration,
|
||||
repositoryUtils: githubRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
@@ -128,7 +128,8 @@ it('Should match generated changelog and replace all occurrences (refs)', async
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration
|
||||
configuration,
|
||||
repositoryUtils: githubRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
@@ -171,7 +172,8 @@ it('Should match ordered ASC', async () => {
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration
|
||||
configuration,
|
||||
repositoryUtils: githubRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
@@ -199,7 +201,8 @@ it('Should match ordered DESC', async () => {
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration
|
||||
configuration,
|
||||
repositoryUtils: githubRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
@@ -226,7 +229,8 @@ it('Should match ordered by title ASC', async () => {
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration
|
||||
configuration,
|
||||
repositoryUtils: githubRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
@@ -255,7 +259,8 @@ it('Should match ordered by title DESC', async () => {
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration
|
||||
configuration,
|
||||
repositoryUtils: githubRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
@@ -284,7 +289,8 @@ it('Should ignore PRs not merged into develop branch', async () => {
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration
|
||||
configuration,
|
||||
repositoryUtils: githubRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
@@ -311,7 +317,8 @@ it('Should ignore PRs not merged into main branch', async () => {
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration
|
||||
configuration,
|
||||
repositoryUtils: githubRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
|
||||
@@ -0,0 +1,336 @@
|
||||
import {checkExportedData, mergeConfiguration, resolveConfiguration} from '../src/utils'
|
||||
import {buildChangelog} from '../src/transform'
|
||||
import {pullData} from '../src/pr-collector/prCollector'
|
||||
import {GiteaRepository} from '../src/repositories/GiteaRepository'
|
||||
|
||||
jest.setTimeout(180000)
|
||||
|
||||
// load octokit instance
|
||||
const enablePullData = true // if false -> use cache for data
|
||||
/**
|
||||
* Before starting testing, you should manually clone the repository
|
||||
* cd /tmp && git clone https://gitea.com/jolheiser/sip
|
||||
*/
|
||||
|
||||
const token = process.env.GITEA_TOKEN || ''
|
||||
const workingDirectory = '/tmp/sip/'
|
||||
const owner = 'jolheiser'
|
||||
const repo = 'sip'
|
||||
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
|
||||
const configurationFile = 'configs/configuration_gitea.json'
|
||||
it('[Gitea] Should have changelog (tags)', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
|
||||
|
||||
const options = {
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
fromTag: {name: 'v0.5.0'},
|
||||
toTag: {name: 'master'},
|
||||
includeOpen: false,
|
||||
failOnError: false,
|
||||
fetchViaCommits: true,
|
||||
fetchReviewers: false,
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration,
|
||||
repositoryUtils: giteaRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
data = await pullData(giteaRepository, options)
|
||||
} else {
|
||||
data = checkExportedData(false, 'caches/rcba_0.0.2-0.0.3_cache.json')
|
||||
}
|
||||
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`## 🚀 Features
|
||||
|
||||
- Add attachment removal and change message
|
||||
- PR: #36
|
||||
|
||||
## 🐛 Fixes
|
||||
|
||||
- Fix drone-gitea-main
|
||||
- PR: #38
|
||||
|
||||
`)
|
||||
})
|
||||
|
||||
it('[Gitea] Should match generated changelog (tags)', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
|
||||
const options = {
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
fromTag: {name: 'v0.5.0'},
|
||||
toTag: {name: 'master'},
|
||||
includeOpen: false,
|
||||
failOnError: false,
|
||||
fetchViaCommits: true,
|
||||
fetchReviewers: false,
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration,
|
||||
repositoryUtils: giteaRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
data = await pullData(giteaRepository, options)
|
||||
} else {
|
||||
data = checkExportedData(false, 'caches/rcba_0.0.1-0.0.3_cache.json')
|
||||
}
|
||||
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`## 🚀 Features
|
||||
|
||||
- Add attachment removal and change message
|
||||
- PR: #36
|
||||
|
||||
## 🐛 Fixes
|
||||
|
||||
- Fix drone-gitea-main
|
||||
- PR: #38
|
||||
|
||||
`)
|
||||
})
|
||||
|
||||
it('[Gitea] Should match generated changelog (refs)', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_all_placeholders.json'))
|
||||
|
||||
const options = {
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
fromTag: {name: '3e49adf6047960a03f53346bbececb3ce7e0809b'},
|
||||
toTag: {name: '894a641ef86c444dccfa55eca457186b5e10da95'},
|
||||
includeOpen: false,
|
||||
failOnError: false,
|
||||
fetchViaCommits: true,
|
||||
fetchReviewers: false,
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration,
|
||||
repositoryUtils: giteaRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
data = await pullData(giteaRepository, options)
|
||||
} else {
|
||||
data = checkExportedData(false, 'caches/rcba_5ec7a2-fa3788_cache.json')
|
||||
}
|
||||
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`## 📦 Uncategorized
|
||||
|
||||
Add release attachments
|
||||
26
|
||||
https://gitea.com/jolheiser/sip/pulls/26
|
||||
2020-09-16T18:07:32.000Z
|
||||
jolheiser
|
||||
enhancement
|
||||
0.5.0
|
||||
Resolves #25
|
||||
|
||||
|
||||
Refactor
|
||||
29
|
||||
https://gitea.com/jolheiser/sip/pulls/29
|
||||
2020-09-17T16:25:11.000Z
|
||||
jolheiser
|
||||
enhancement
|
||||
0.5.0
|
||||
Fixes #27
|
||||
|
||||
Fixes #28
|
||||
|
||||
This PR refactors and cleans up packages.
|
||||
|
||||
It also scans CLI flags into variables for fewer footguns.
|
||||
|
||||
|
||||
|
||||
`)
|
||||
})
|
||||
|
||||
it('[Gitea] Should match generated changelog and replace all occurrences (refs)', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_replace_all_placeholders.json'))
|
||||
const options = {
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
fromTag: {name: '3e49adf6047960a03f53346bbececb3ce7e0809b'},
|
||||
toTag: {name: '894a641ef86c444dccfa55eca457186b5e10da95'},
|
||||
includeOpen: false,
|
||||
failOnError: false,
|
||||
fetchViaCommits: true,
|
||||
fetchReviewers: false,
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration,
|
||||
repositoryUtils: giteaRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
data = await pullData(giteaRepository, options)
|
||||
} else {
|
||||
data = checkExportedData(false, 'caches/rcba_5ec7a2-fa3788_cache.json')
|
||||
}
|
||||
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`## 📦 Uncategorized
|
||||
|
||||
Add release attachments
|
||||
Add release attachments
|
||||
26
|
||||
https://gitea.com/jolheiser/sip/pulls/26
|
||||
2020-09-16T18:07:32.000Z
|
||||
jolheiser
|
||||
jolheiser
|
||||
enhancement
|
||||
0.5.0
|
||||
Resolves #25
|
||||
|
||||
|
||||
Refactor
|
||||
Refactor
|
||||
29
|
||||
https://gitea.com/jolheiser/sip/pulls/29
|
||||
2020-09-17T16:25:11.000Z
|
||||
jolheiser
|
||||
jolheiser
|
||||
enhancement
|
||||
0.5.0
|
||||
Fixes #27
|
||||
|
||||
Fixes #28
|
||||
|
||||
This PR refactors and cleans up packages.
|
||||
|
||||
It also scans CLI flags into variables for fewer footguns.
|
||||
|
||||
|
||||
|
||||
`)
|
||||
})
|
||||
|
||||
it('[Gitea] Should match ordered ASC', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
|
||||
configuration.categories.pop() // drop `uncategorized` category
|
||||
const options = {
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
fromTag: {name: 'v0.1.0'},
|
||||
toTag: {name: 'master'},
|
||||
includeOpen: false,
|
||||
failOnError: false,
|
||||
fetchViaCommits: false,
|
||||
fetchReviewers: false,
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration,
|
||||
repositoryUtils: giteaRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
data = await pullData(giteaRepository, options)
|
||||
} else {
|
||||
data = checkExportedData(false, 'caches/rcba_0.3.0-0.5.0_cache.json')
|
||||
}
|
||||
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`## 🚀 Features
|
||||
|
||||
- Add Drone and releases
|
||||
- PR: #2
|
||||
- Add search filters
|
||||
- PR: #8
|
||||
- Add qualifier module
|
||||
- PR: #10
|
||||
- Add create repo command
|
||||
- PR: #13
|
||||
- Add release support and CSV output
|
||||
- PR: #16
|
||||
- Add open functionality
|
||||
- PR: #21
|
||||
- Add changelog for 0.3.0 and 0.4.0
|
||||
- PR: #22
|
||||
- Add release attachments
|
||||
- PR: #26
|
||||
- Add attachment removal and change message
|
||||
- PR: #36
|
||||
|
||||
## 🐛 Fixes
|
||||
|
||||
- Fix PR head nil panic
|
||||
- PR: #7
|
||||
- Fix Drone release
|
||||
- PR: #14
|
||||
|
||||
`)
|
||||
})
|
||||
|
||||
it('[Gitea] Should match ordered DESC', async () => {
|
||||
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_gitea_desc.json'))
|
||||
configuration.categories.pop() // drop `uncategorized` category
|
||||
const options = {
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
fromTag: {name: 'v0.1.0'},
|
||||
toTag: {name: 'master'},
|
||||
includeOpen: false,
|
||||
failOnError: false,
|
||||
fetchViaCommits: false,
|
||||
fetchReviewers: false,
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration,
|
||||
repositoryUtils: giteaRepository
|
||||
}
|
||||
let data: any
|
||||
if (enablePullData) {
|
||||
data = await pullData(giteaRepository, options)
|
||||
} else {
|
||||
data = checkExportedData(false, 'caches/rcba_0.3.0-0.5.0_cache.json')
|
||||
}
|
||||
const changeLog = buildChangelog(data!.diffInfo, data!.mergedPullRequests, options)
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`## 🚀 Features
|
||||
|
||||
- Add attachment removal and change message
|
||||
- PR: #36
|
||||
- Add release attachments
|
||||
- PR: #26
|
||||
- Add changelog for 0.3.0 and 0.4.0
|
||||
- PR: #22
|
||||
- Add open functionality
|
||||
- PR: #21
|
||||
- Add release support and CSV output
|
||||
- PR: #16
|
||||
- Add create repo command
|
||||
- PR: #13
|
||||
- Add qualifier module
|
||||
- PR: #10
|
||||
- Add search filters
|
||||
- PR: #8
|
||||
- Add Drone and releases
|
||||
- PR: #2
|
||||
|
||||
## 🐛 Fixes
|
||||
|
||||
- Fix Drone release
|
||||
- PR: #14
|
||||
- Fix PR head nil panic
|
||||
- PR: #7
|
||||
|
||||
`)
|
||||
})
|
||||
|
||||
/*
|
||||
* I delete these test cases about gitea
|
||||
* Should match ordered by title ASC
|
||||
* Should match ordered by title DESC
|
||||
* Should ignore PRs not merged into develop branch
|
||||
*/
|
||||
@@ -1,4 +1,4 @@
|
||||
import {TagInfo, filterTags, prepareAndSortTags} from '../src/pr-collector/tags'
|
||||
import {filterTags, prepareAndSortTags, TagInfo} from '../src/pr-collector/tags'
|
||||
|
||||
jest.setTimeout(180000)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import moment from 'moment'
|
||||
import {Configuration, DefaultConfiguration} from '../src/configuration'
|
||||
import {PullRequestInfo} from '../src/pr-collector/pullRequests'
|
||||
import {DefaultDiffInfo} from '../src/pr-collector/commits'
|
||||
import {GithubRepository} from '../src/repositories/GithubRepository'
|
||||
|
||||
jest.setTimeout(180000)
|
||||
|
||||
@@ -437,6 +438,7 @@ it('Use empty_content for empty category', async () => {
|
||||
)
|
||||
})
|
||||
|
||||
const repositoryUtils = new GithubRepository(process.env.GITEA_TOKEN || '', undefined, '.')
|
||||
it('Commit SHA-1 in commitMode', async () => {
|
||||
const customConfig = Object.assign({}, DefaultConfiguration)
|
||||
customConfig.sort = 'DESC'
|
||||
@@ -453,7 +455,8 @@ it('Commit SHA-1 in commitMode', async () => {
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: true,
|
||||
configuration: customConfig
|
||||
configuration: customConfig,
|
||||
repositoryUtils: repositoryUtils
|
||||
})
|
||||
|
||||
expect(resultChangelog).toStrictEqual(`## 🚀 Features\n\nsha1-3\nsha1-1\n\n## 🐛 Fixes\n\nsha1-3\nsha1-2\n\n`)
|
||||
@@ -474,7 +477,8 @@ it('Release Diff', async () => {
|
||||
fetchReleaseInformation: true,
|
||||
fetchReviews: false,
|
||||
commitMode: true,
|
||||
configuration: customConfig
|
||||
configuration: customConfig,
|
||||
repositoryUtils: repositoryUtils
|
||||
})
|
||||
|
||||
expect(resultChangelog).toStrictEqual(`https://github.com/mikepenz/release-changelog-builder-action/compare/v2.8.0...v2.8.1\n`)
|
||||
@@ -678,6 +682,7 @@ function buildChangelogTest(config: Configuration, prs: PullRequestInfo[]): stri
|
||||
fetchReleaseInformation: false,
|
||||
fetchReviews: false,
|
||||
commitMode: false,
|
||||
configuration: config
|
||||
configuration: config,
|
||||
repositoryUtils: repositoryUtils
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user