From 49d12f5b1e6adadcb303e1f0609034e09d4e7d90 Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Mon, 19 Oct 2020 17:28:28 +0200 Subject: [PATCH] - introduce tests covering the action process itself --- __tests__/main.test.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 __tests__/main.test.ts diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts new file mode 100644 index 0000000..3536872 --- /dev/null +++ b/__tests__/main.test.ts @@ -0,0 +1,34 @@ +import * as path from 'path'; +import * as process from 'process' +import * as cp from 'child_process' + +test('missing values should result in failure', () => { + process.env['GITHUB_WORKSPACE'] = '.' + process.env['INPUT_CONFIGURATION'] = 'configuration.json' + const ip = path.join(__dirname, '..', 'lib', 'main.js') + const options: cp.ExecSyncOptions = { + env: process.env + } + try { + cp.execSync(`node ${ip}`, options).toString() + fail("Should not succeed, because values miss") + } catch (error) { + console.log(`correctly failed due to: ${error}`) + } +}) + +test('missing values should result in failure', () => { + 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' + + 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 +}) \ No newline at end of file