fix: update log level to use enum
This commit is contained in:
parent
0af369cc61
commit
13d42e8b6f
|
@ -79,7 +79,7 @@ export function friendlyError(ctx: VisitorContext, err: ErrorObject): VisitorErr
|
|||
data: {
|
||||
err,
|
||||
},
|
||||
level: 'error',
|
||||
level: LogLevel.Error,
|
||||
msg: friendlyErrorMessage(ctx, err),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import { ConsoleLogger } from 'noicejs';
|
||||
import { ConsoleLogger, LogLevel } from 'noicejs';
|
||||
import { mock, spy, stub } from 'sinon';
|
||||
|
||||
import { createRuleSelector, createRuleSources, resolveRules, visitRules } from '../../src/rule';
|
||||
|
@ -10,21 +10,21 @@ import { describeLeaks, itLeaks } from '../helpers/async';
|
|||
const TEST_RULES = [new SchemaRule({
|
||||
check: {},
|
||||
desc: '',
|
||||
level: 'info',
|
||||
level: LogLevel.Info,
|
||||
name: 'foo',
|
||||
select: '$',
|
||||
tags: ['all', 'foo'],
|
||||
}), new SchemaRule({
|
||||
check: {},
|
||||
desc: '',
|
||||
level: 'warn',
|
||||
level: LogLevel.Warn,
|
||||
name: 'bar',
|
||||
select: '$',
|
||||
tags: ['all', 'test'],
|
||||
}), new SchemaRule({
|
||||
check: {},
|
||||
desc: '',
|
||||
level: 'warn',
|
||||
level: LogLevel.Warn,
|
||||
name: 'bin',
|
||||
select: '$',
|
||||
tags: ['all', 'test'],
|
||||
|
@ -34,7 +34,7 @@ describeLeaks('rule resolver', async () => {
|
|||
describeLeaks('include by level', async () => {
|
||||
itLeaks('should include info rules', async () => {
|
||||
const info = await resolveRules(TEST_RULES, createRuleSelector({
|
||||
includeLevel: ['info'],
|
||||
includeLevel: [LogLevel.Info],
|
||||
}));
|
||||
|
||||
expect(info.length).to.equal(1);
|
||||
|
@ -43,7 +43,7 @@ describeLeaks('rule resolver', async () => {
|
|||
|
||||
itLeaks('should include warn rules', async () => {
|
||||
const info = await resolveRules(TEST_RULES, createRuleSelector({
|
||||
includeLevel: ['warn'],
|
||||
includeLevel: [LogLevel.Warn],
|
||||
}));
|
||||
|
||||
expect(info.length).to.equal(2);
|
||||
|
@ -115,7 +115,7 @@ describeLeaks('rule visitor', async () => {
|
|||
const rule = new SchemaRule({
|
||||
check: {},
|
||||
desc: '',
|
||||
level: 'info',
|
||||
level: LogLevel.Info,
|
||||
name: 'foo',
|
||||
select: '$',
|
||||
tags: [],
|
||||
|
@ -147,7 +147,7 @@ describeLeaks('rule visitor', async () => {
|
|||
const rule = new SchemaRule({
|
||||
check: {},
|
||||
desc: '',
|
||||
level: 'info',
|
||||
level: LogLevel.Info,
|
||||
name: 'foo',
|
||||
select: '$',
|
||||
tags: [],
|
||||
|
@ -184,7 +184,7 @@ describeLeaks('rule visitor', async () => {
|
|||
const rule = new SchemaRule({
|
||||
check: {},
|
||||
desc: '',
|
||||
level: 'info',
|
||||
level: LogLevel.Info,
|
||||
name: 'foo',
|
||||
select: '$.foo.*',
|
||||
tags: [],
|
||||
|
@ -217,7 +217,7 @@ describeLeaks('rule visitor', async () => {
|
|||
const rule = new SchemaRule({
|
||||
check: {},
|
||||
desc: '',
|
||||
level: 'info',
|
||||
level: LogLevel.Info,
|
||||
name: 'foo',
|
||||
select: '$.foo.*',
|
||||
tags: [],
|
||||
|
@ -227,7 +227,7 @@ describeLeaks('rule visitor', async () => {
|
|||
changes: [],
|
||||
errors: [{
|
||||
data: {},
|
||||
level: 'error',
|
||||
level: LogLevel.Error,
|
||||
msg: 'kaboom!',
|
||||
}],
|
||||
}));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import { NullLogger } from 'noicejs';
|
||||
import { LogLevel, NullLogger } from 'noicejs';
|
||||
import { stub } from 'sinon';
|
||||
|
||||
import { friendlyError, SchemaRule } from '../../src/rule/SchemaRule';
|
||||
|
@ -26,7 +26,7 @@ describeLeaks('schema rule', async () => {
|
|||
const rule = new SchemaRule({
|
||||
check: {},
|
||||
desc: '',
|
||||
level: 'info',
|
||||
level: LogLevel.Info,
|
||||
name: 'foo',
|
||||
select: '$.foo',
|
||||
tags: [],
|
||||
|
@ -60,7 +60,7 @@ describeLeaks('schema rule', async () => {
|
|||
},
|
||||
type: 'object',
|
||||
},
|
||||
level: 'info',
|
||||
level: LogLevel.Info,
|
||||
name: 'foo',
|
||||
select: '$.foo',
|
||||
tags: [],
|
||||
|
@ -82,7 +82,7 @@ describeLeaks('schema rule', async () => {
|
|||
const rule = new SchemaRule({
|
||||
check: undefined,
|
||||
desc: TEST_NAME,
|
||||
level: 'info',
|
||||
level: LogLevel.Info,
|
||||
name: TEST_NAME,
|
||||
select: '$.foo',
|
||||
tags: [],
|
||||
|
@ -113,7 +113,7 @@ describeLeaks('schema rule', async () => {
|
|||
check,
|
||||
desc: TEST_NAME,
|
||||
filter,
|
||||
level: 'info',
|
||||
level: LogLevel.Info,
|
||||
name: TEST_NAME,
|
||||
select: '$.foo',
|
||||
tags: [],
|
||||
|
@ -144,7 +144,7 @@ describeLeaks('schema rule', async () => {
|
|||
check: undefined,
|
||||
desc: TEST_NAME,
|
||||
filter: {},
|
||||
level: 'info',
|
||||
level: LogLevel.Info,
|
||||
name: TEST_NAME,
|
||||
select: '$.foo',
|
||||
tags: [],
|
||||
|
@ -163,7 +163,7 @@ describe('friendly errors', () => {
|
|||
const rule = new SchemaRule({
|
||||
check: {},
|
||||
desc: TEST_NAME,
|
||||
level: 'info',
|
||||
level: LogLevel.Info,
|
||||
name: TEST_NAME,
|
||||
select: '',
|
||||
tags: [TEST_NAME],
|
||||
|
@ -194,7 +194,7 @@ describe('friendly errors', () => {
|
|||
const rule = new SchemaRule({
|
||||
check: {},
|
||||
desc: TEST_NAME,
|
||||
level: 'info',
|
||||
level: LogLevel.Info,
|
||||
name: TEST_NAME,
|
||||
select: '',
|
||||
tags: [TEST_NAME],
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import { ConsoleLogger } from 'noicejs';
|
||||
import { ConsoleLogger, LogLevel } from 'noicejs';
|
||||
|
||||
import { VisitorContext } from '../../src/visitor/VisitorContext';
|
||||
|
||||
|
@ -23,7 +23,7 @@ describe('visitor context', () => {
|
|||
data: {
|
||||
foo: 2,
|
||||
},
|
||||
level: 'info',
|
||||
level: LogLevel.Info,
|
||||
msg: 'uh oh',
|
||||
}],
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue