Skip to content

Commit 63fff9e

Browse files
committed
fix: Changed error message type for multiple resources found
1 parent ba3fd92 commit 63fff9e

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codify-plugin-lib",
3-
"version": "1.0.149",
3+
"version": "1.0.150",
44
"description": "Library plugin library",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",

src/plugin/plugin.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -482,13 +482,12 @@ describe('Plugin tests', () => {
482482

483483
const testPlugin = Plugin.create('testPlugin', [resource as any]);
484484

485-
const validate1 = await testPlugin.validate({
486-
configs: [{ core: { type: 'ssh-config' }, parameters: { propA: 'a' } }, {
487-
core: { type: 'ssh-config' },
488-
parameters: { propB: 'b' }
489-
}]
490-
})
491-
492-
expect(validate1.resourceValidations.every((r) => r.isValid)).to.be.false;
485+
await expect(() => testPlugin.validate({
486+
configs: [{ core: { type: 'ssh-config' }, parameters: { propA: 'a' } }, {
487+
core: { type: 'ssh-config' },
488+
parameters: { propB: 'b' }
489+
}]
490+
})
491+
).rejects.toThrowError();
493492
})
494493
});

src/plugin/plugin.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,11 @@ export class Plugin {
178178
});
179179

180180
if (invalidMultipleConfigs.length > 0) {
181-
validationResults.push(...invalidMultipleConfigs.map(([k, v]) => ({
182-
resourceType: k,
183-
schemaValidationErrors: [],
184-
customValidationErrorMessage: `Multiple of resource type: ${k} found in configs. Only allowed 1.`,
185-
isValid: false,
186-
})));
181+
throw new Error(
182+
`Multiples of the following configs were found but only 1 is allowed.
183+
184+
[${invalidMultipleConfigs.map(([k]) => k).join(', ')}]
185+
`)
187186
}
188187

189188
await this.crossValidateResources(data.configs);

0 commit comments

Comments
 (0)