- fix formatting

- apply some smaller fixes
- enable cache for 1 gitea test (no need to use API)
- do not cache and export token in cache
- speed up main.test.ts
This commit is contained in:
Mike Penz
2023-11-05 10:05:00 +00:00
committed by GitHub
parent e86f2bbfce
commit 8afbd5a789
19 changed files with 1145 additions and 4267 deletions
@@ -0,0 +1,793 @@
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/mikepenz/sip
*
* (Forked from: 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] 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] 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] 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`)
})
@@ -0,0 +1,349 @@
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 = false
/**
* if false -> use cache for data
* Use the below snippet to export the cache:
*
* writeCacheData({
* mergedPullRequests: data.mergedPullRequests,
* diffInfo: data.diffInfo,
* options
* }, 'caches/gitea_rcba_0.1.0-master_cache.json')
*/
/**
* Before starting testing, you should manually clone the repository
* cd /tmp && git clone https://gitea.com/mikepenz/sip
*
* (Forked from: 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/gitea_rcba_0.5.0-master_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/gitea_rcba_0.5.0-master_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/gitea_rcba_3e49adf-894a64_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/gitea_rcba_3e49adf-894a64_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/gitea_rcba_0.1.0-master_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/gitea_rcba_0.1.0-master_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
*/