Adding more tests for the config file.
This commit is contained in:
@@ -3,7 +3,8 @@ import {expect, test, jest, beforeEach} from '@jest/globals'
|
|||||||
import {readConfig} from '../src/config'
|
import {readConfig} from '../src/config'
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
/* reset to our defaults after every test run */
|
// reset to our defaults after every test run
|
||||||
|
// TODO find out what the proper way of passing action inputs in tests is
|
||||||
delete process.env['INPUT_FAIL-ON-SEVERITY']
|
delete process.env['INPUT_FAIL-ON-SEVERITY']
|
||||||
delete process.env['INPUT_ALLOWED-LICENSES']
|
delete process.env['INPUT_ALLOWED-LICENSES']
|
||||||
delete process.env['INPUT_DENY-LICENSES']
|
delete process.env['INPUT_DENY-LICENSES']
|
||||||
@@ -36,4 +37,13 @@ test('it raises an error if both an allow and denylist are specified', async ()
|
|||||||
expect(() => readConfig()).toThrow()
|
expect(() => readConfig()).toThrow()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('it raises an error when given an unknown severity', async () => {})
|
test('it raises an error when given an unknown severity', async () => {
|
||||||
|
process.env['INPUT_FAIL-ON-SEVERITY'] = 'zombies!'
|
||||||
|
expect(() => readConfig()).toThrow()
|
||||||
|
})
|
||||||
|
|
||||||
|
test('it works on uppercase severities', async () => {
|
||||||
|
process.env['INPUT_FAIL-ON-SEVERITY'] = 'CRITICAL'
|
||||||
|
const options = readConfig()
|
||||||
|
expect(options.fail_on_severity).toEqual('critical')
|
||||||
|
})
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ export function readConfig(): ConfigurationOptions {
|
|||||||
const allowedLicenses = core.getInput('allowed-licenses')
|
const allowedLicenses = core.getInput('allowed-licenses')
|
||||||
const denyLicenses = core.getInput('deny-licenses')
|
const denyLicenses = core.getInput('deny-licenses')
|
||||||
|
|
||||||
options.fail_on_severity = severity as Severity
|
options.fail_on_severity = severity.toLowerCase() as Severity
|
||||||
|
|
||||||
if (allowedLicenses.length > 0) {
|
if (allowedLicenses.length > 0) {
|
||||||
options.allow_licenses = allowedLicenses.split(',').map(s => s.trim())
|
options.allow_licenses = allowedLicenses.split(',').map(s => s.trim())
|
||||||
|
|||||||
Reference in New Issue
Block a user