- add support for configs to be provided from file and json
- define priority on the config json from YML, followed by file, last with the default value - Simplify code by merging configs right away - thanks for the suggestion @dtcMLOps
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import {mergeConfiguration, parseConfiguration, resolveConfiguration} from '../src/utils'
|
||||
|
||||
jest.setTimeout(180000)
|
||||
|
||||
it('Configurations are merged correctly', async () => {
|
||||
const configurationJson = parseConfiguration(`{
|
||||
"sort": "DESC",
|
||||
"empty_template": "- no magic changes",
|
||||
"trim_values": true
|
||||
}`)
|
||||
const configurationFile = resolveConfiguration('', 'configs/configuration.json')
|
||||
|
||||
const mergedConfiguration = mergeConfiguration(configurationJson, configurationFile)
|
||||
|
||||
console.log(mergedConfiguration)
|
||||
expect(JSON.stringify(mergedConfiguration)).toEqual(`{\"max_tags_to_fetch\":200,\"max_pull_requests\":1000,\"max_back_track_time_days\":1000,\"exclude_merge_branches\":[],\"sort\":\"DESC\",\"template\":\"$\{\{CHANGELOG}}\",\"pr_template\":\"- $\{\{TITLE}}\\n - PR: #$\{\{NUMBER}}\",\"empty_template\":\"- no magic changes\",\"categories\":[{\"title\":\"## 🚀 Features\",\"labels\":[\"feature\"]},{\"title\":\"## 🐛 Fixes\",\"labels\":[\"fix\"]},{\"title\":\"## 🧪 Tests\",\"labels\":[\"test\"]}],\"ignore_labels\":[\"ignore\"],\"label_extractor\":[],\"transformers\":[],\"tag_resolver\":{\"method\":\"semver\"},\"base_branches\":[],\"custom_placeholders\":[],\"trim_values\":true}`)
|
||||
})
|
||||
Reference in New Issue
Block a user