fix: clarify EPLUGINCONF error message
The message now specify if the step is required and if it allows to configure multiple plugins.
This commit is contained in:
@@ -159,18 +159,15 @@ test('Merge global options with plugin options', async t => {
|
||||
t.deepEqual(result.pluginConfig, {localOpt: 'local', globalOpt: 'global', otherOpt: 'locally-defined'});
|
||||
});
|
||||
|
||||
test('Throw an error if plugins configuration are missing a path for plugin pipeline', t => {
|
||||
const errors = [...t.throws(() => getPlugins({cwd, logger: t.context.logger, options: {verifyConditions: {}}}, {}))];
|
||||
|
||||
t.is(errors[0].name, 'SemanticReleaseError');
|
||||
t.is(errors[0].code, 'EPLUGINCONF');
|
||||
});
|
||||
|
||||
test('Throw an error if an array of plugin configuration is missing a path for plugin pipeline', t => {
|
||||
test('Throw an error if plugins configuration are invalid', t => {
|
||||
const errors = [
|
||||
...t.throws(() =>
|
||||
getPlugins(
|
||||
{cwd, logger: t.context.logger, options: {verifyConditions: [{path: '@semantic-release/npm'}, {}]}},
|
||||
{
|
||||
cwd,
|
||||
logger: t.context.logger,
|
||||
options: {verifyConditions: {}, analyzeCommits: [], verifyRelease: [{}], generateNotes: [{path: null}]},
|
||||
},
|
||||
{}
|
||||
)
|
||||
),
|
||||
@@ -178,4 +175,10 @@ test('Throw an error if an array of plugin configuration is missing a path for p
|
||||
|
||||
t.is(errors[0].name, 'SemanticReleaseError');
|
||||
t.is(errors[0].code, 'EPLUGINCONF');
|
||||
t.is(errors[1].name, 'SemanticReleaseError');
|
||||
t.is(errors[1].code, 'EPLUGINCONF');
|
||||
t.is(errors[2].name, 'SemanticReleaseError');
|
||||
t.is(errors[2].code, 'EPLUGINCONF');
|
||||
t.is(errors[3].name, 'SemanticReleaseError');
|
||||
t.is(errors[3].code, 'EPLUGINCONF');
|
||||
});
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import test from 'ava';
|
||||
import {validateConfig} from '../../lib/plugins/utils';
|
||||
|
||||
test('Validate multiple/optional plugin configuration', t => {
|
||||
const type = {multiple: true, required: false};
|
||||
t.false(validateConfig(type, {}));
|
||||
t.false(validateConfig(type, {path: null}));
|
||||
|
||||
t.true(validateConfig(type, {path: 'plugin-path.js'}));
|
||||
t.true(validateConfig(type));
|
||||
t.true(validateConfig(type, 'plugin-path.js'));
|
||||
t.true(validateConfig(type, ['plugin-path.js']));
|
||||
t.true(validateConfig(type, () => {}));
|
||||
t.true(validateConfig(type, [{path: 'plugin-path.js'}, 'plugin-path.js', () => {}]));
|
||||
});
|
||||
|
||||
test('Validate multiple/required plugin configuration', t => {
|
||||
const type = {multiple: true, required: true};
|
||||
t.false(validateConfig(type, {}));
|
||||
t.false(validateConfig(type, {path: null}));
|
||||
t.false(validateConfig(type));
|
||||
|
||||
t.true(validateConfig(type, {path: 'plugin-path.js'}));
|
||||
t.true(validateConfig(type, 'plugin-path.js'));
|
||||
t.true(validateConfig(type, ['plugin-path.js']));
|
||||
t.true(validateConfig(type, () => {}));
|
||||
t.true(validateConfig(type, [{path: 'plugin-path.js'}, 'plugin-path.js', () => {}]));
|
||||
});
|
||||
|
||||
test('Validate single/required plugin configuration', t => {
|
||||
const type = {multiple: false, required: true};
|
||||
|
||||
t.false(validateConfig(type, {}));
|
||||
t.false(validateConfig(type, {path: null}));
|
||||
t.false(validateConfig(type, []));
|
||||
t.false(validateConfig(type));
|
||||
t.false(validateConfig(type, [{path: 'plugin-path.js'}, 'plugin-path.js', () => {}]));
|
||||
|
||||
t.true(validateConfig(type, {path: 'plugin-path.js'}));
|
||||
t.true(validateConfig(type, 'plugin-path.js'));
|
||||
t.true(validateConfig(type, ['plugin-path.js']));
|
||||
t.true(validateConfig(type, () => {}));
|
||||
});
|
||||
|
||||
test('Validate single/optional plugin configuration', t => {
|
||||
const type = {multiple: false, required: false};
|
||||
|
||||
t.false(validateConfig(type, {}));
|
||||
t.false(validateConfig(type, {path: null}));
|
||||
t.false(validateConfig(type, [{path: 'plugin-path.js'}, 'plugin-path.js', () => {}]));
|
||||
|
||||
t.true(validateConfig(type));
|
||||
t.true(validateConfig(type, []));
|
||||
t.true(validateConfig(type, {path: 'plugin-path.js'}));
|
||||
t.true(validateConfig(type, 'plugin-path.js'));
|
||||
t.true(validateConfig(type, ['plugin-path.js']));
|
||||
t.true(validateConfig(type, () => {}));
|
||||
});
|
||||
Reference in New Issue
Block a user