- introduce new API allowing to write changelog directly to result file

- introduce test case for writing a file
This commit is contained in:
Mike Penz
2020-12-30 17:49:41 +01:00
parent 9a0355af98
commit a463f188c1
7 changed files with 13179 additions and 5 deletions
+27 -1
View File
@@ -1,6 +1,7 @@
import * as path from 'path'
import * as process from 'process'
import * as cp from 'child_process'
import * as fs from 'fs'
test('missing values should result in failure', () => {
process.env['GITHUB_WORKSPACE'] = '.'
@@ -17,7 +18,7 @@ test('missing values should result in failure', () => {
}
})
test('missing values should result in failure', () => {
test('complete input should succeed', () => {
process.env['GITHUB_WORKSPACE'] = '.'
process.env['INPUT_CONFIGURATION'] = 'configuration.json'
process.env['INPUT_OWNER'] = 'mikepenz'
@@ -31,4 +32,29 @@ test('missing values should result in failure', () => {
}
const result = cp.execSync(`node ${ip}`, options).toString()
// should succeed
expect(result).toBeDefined()
})
test('should write result to file', () => {
process.env['GITHUB_WORKSPACE'] = '.'
process.env['INPUT_CONFIGURATION'] = 'configuration.json'
process.env['INPUT_OWNER'] = 'mikepenz'
process.env['INPUT_REPO'] = 'release-changelog-builder-action'
process.env['INPUT_FROMTAG'] = 'v0.3.0'
process.env['INPUT_TOTAG'] = 'v0.5.0'
process.env['INPUT_OUTPUTFILE'] = 'test.md'
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
expect(result).toBeDefined()
const readOutput = fs.readFileSync("test.md")
fs.unlinkSync("test.md")
expect(readOutput.toString()).not.toBe('')
})