1
0
Fork 0

fix(tests): cover rule module error handling, exclude by level

This commit is contained in:
ssube 2019-11-16 18:27:39 -06:00 committed by Sean Sube
parent c0eb3e0bfc
commit b3fa9dd9be
2 changed files with 27 additions and 0 deletions

View File

@ -157,5 +157,20 @@ describeLeaks('load rule module helper', async () => {
expect(rules.length).to.equal(1);
});
itLeaks('should handle errors loading rule modules', async () => {
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
const requireStub = stub().throws(new Error('could not load this module')) as any;
const ctx = new VisitorContext({
logger: NullLogger.global,
schemaOptions: {
coerce: false,
defaults: false,
mutate: false,
},
});
return expect(loadRuleModules(['test'], ctx, requireStub)).to.eventually.deep.equal([]);
});
itLeaks('should validate rule module exports');
});

View File

@ -97,6 +97,18 @@ describeLeaks('rule resolver', async () => {
expect(rules[0]).to.equal(TEST_RULES[0]);
});
});
describeLeaks('exclude by level', async () => {
itLeaks('should exclude warn rules', async () => {
const rules = await resolveRules(TEST_RULES, createRuleSelector({
excludeLevel: [LogLevel.Warn],
includeTag: ['all'],
}));
expect(rules.length).to.equal(1);
expect(rules[0]).to.equal(TEST_RULES[0]);
});
});
});
describe('create rule sources helper', () => {