pull:初次提交
This commit is contained in:
26
n8n-n8n-1.109.2/packages/workflow/test/errors/base/operational.error.test.ts
Executable file
26
n8n-n8n-1.109.2/packages/workflow/test/errors/base/operational.error.test.ts
Executable file
@@ -0,0 +1,26 @@
|
||||
import { BaseError } from '../../../src/errors/base/base.error';
|
||||
import { OperationalError } from '../../../src/errors/base/operational.error';
|
||||
|
||||
describe('OperationalError', () => {
|
||||
it('should be an instance of OperationalError', () => {
|
||||
const error = new OperationalError('test');
|
||||
expect(error).toBeInstanceOf(OperationalError);
|
||||
});
|
||||
|
||||
it('should be an instance of BaseError', () => {
|
||||
const error = new OperationalError('test');
|
||||
expect(error).toBeInstanceOf(BaseError);
|
||||
});
|
||||
|
||||
it('should have correct defaults', () => {
|
||||
const error = new OperationalError('test');
|
||||
expect(error.level).toBe('warning');
|
||||
expect(error.shouldReport).toBe(false);
|
||||
});
|
||||
|
||||
it('should allow overriding the default level and shouldReport', () => {
|
||||
const error = new OperationalError('test', { level: 'error', shouldReport: true });
|
||||
expect(error.level).toBe('error');
|
||||
expect(error.shouldReport).toBe(true);
|
||||
});
|
||||
});
|
||||
26
n8n-n8n-1.109.2/packages/workflow/test/errors/base/unexpected.error.test.ts
Executable file
26
n8n-n8n-1.109.2/packages/workflow/test/errors/base/unexpected.error.test.ts
Executable file
@@ -0,0 +1,26 @@
|
||||
import { BaseError } from '../../../src/errors/base/base.error';
|
||||
import { UnexpectedError } from '../../../src/errors/base/unexpected.error';
|
||||
|
||||
describe('UnexpectedError', () => {
|
||||
it('should be an instance of UnexpectedError', () => {
|
||||
const error = new UnexpectedError('test');
|
||||
expect(error).toBeInstanceOf(UnexpectedError);
|
||||
});
|
||||
|
||||
it('should be an instance of BaseError', () => {
|
||||
const error = new UnexpectedError('test');
|
||||
expect(error).toBeInstanceOf(BaseError);
|
||||
});
|
||||
|
||||
it('should have correct defaults', () => {
|
||||
const error = new UnexpectedError('test');
|
||||
expect(error.level).toBe('error');
|
||||
expect(error.shouldReport).toBe(true);
|
||||
});
|
||||
|
||||
it('should allow overriding the default level and shouldReport', () => {
|
||||
const error = new UnexpectedError('test', { level: 'fatal', shouldReport: false });
|
||||
expect(error.level).toBe('fatal');
|
||||
expect(error.shouldReport).toBe(false);
|
||||
});
|
||||
});
|
||||
26
n8n-n8n-1.109.2/packages/workflow/test/errors/base/user.error.test.ts
Executable file
26
n8n-n8n-1.109.2/packages/workflow/test/errors/base/user.error.test.ts
Executable file
@@ -0,0 +1,26 @@
|
||||
import { BaseError } from '../../../src/errors/base/base.error';
|
||||
import { UserError } from '../../../src/errors/base/user.error';
|
||||
|
||||
describe('UserError', () => {
|
||||
it('should be an instance of UserError', () => {
|
||||
const error = new UserError('test');
|
||||
expect(error).toBeInstanceOf(UserError);
|
||||
});
|
||||
|
||||
it('should be an instance of BaseError', () => {
|
||||
const error = new UserError('test');
|
||||
expect(error).toBeInstanceOf(BaseError);
|
||||
});
|
||||
|
||||
it('should have correct defaults', () => {
|
||||
const error = new UserError('test');
|
||||
expect(error.level).toBe('info');
|
||||
expect(error.shouldReport).toBe(false);
|
||||
});
|
||||
|
||||
it('should allow overriding the default level and shouldReport', () => {
|
||||
const error = new UserError('test', { level: 'warning', shouldReport: true });
|
||||
expect(error.level).toBe('warning');
|
||||
expect(error.shouldReport).toBe(true);
|
||||
});
|
||||
});
|
||||
24
n8n-n8n-1.109.2/packages/workflow/test/errors/node.error.test.ts
Executable file
24
n8n-n8n-1.109.2/packages/workflow/test/errors/node.error.test.ts
Executable file
@@ -0,0 +1,24 @@
|
||||
import { mock } from 'vitest-mock-extended';
|
||||
|
||||
import { NodeApiError } from '../../src/errors/node-api.error';
|
||||
import { NodeOperationError } from '../../src/errors/node-operation.error';
|
||||
import type { INode } from '../../src/interfaces';
|
||||
|
||||
describe('NodeError', () => {
|
||||
const node = mock<INode>();
|
||||
|
||||
it('should update re-wrapped error level and message', () => {
|
||||
vi.useFakeTimers({ now: new Date() });
|
||||
|
||||
const apiError = new NodeApiError(node, { message: 'Some error happened', code: 500 });
|
||||
const opsError = new NodeOperationError(node, mock(), { message: 'Some operation failed' });
|
||||
const wrapped1 = new NodeOperationError(node, apiError);
|
||||
const wrapped2 = new NodeOperationError(node, opsError);
|
||||
|
||||
expect(wrapped1.level).toEqual(apiError.level);
|
||||
expect(wrapped1.message).toEqual(apiError.message);
|
||||
expect(wrapped2).toEqual(opsError);
|
||||
|
||||
vi.useRealTimers();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
import { WorkflowActivationError } from '../../src/errors';
|
||||
|
||||
describe('WorkflowActivationError', () => {
|
||||
it('should default to `error` level', () => {
|
||||
const error = new WorkflowActivationError('message');
|
||||
expect(error.level).toBe('error');
|
||||
});
|
||||
|
||||
const cause = new Error('Some error message');
|
||||
|
||||
it('should set `level` based on arg', () => {
|
||||
const firstError = new WorkflowActivationError('message', { level: 'warning', cause });
|
||||
|
||||
expect(firstError.level).toBe('warning');
|
||||
|
||||
const secondError = new WorkflowActivationError('message', { level: 'error', cause });
|
||||
|
||||
expect(secondError.level).toBe('error');
|
||||
});
|
||||
|
||||
test.each([
|
||||
'ETIMEDOUT',
|
||||
'ECONNREFUSED',
|
||||
'EAUTH',
|
||||
'Temporary authentication failure',
|
||||
'Invalid credentials',
|
||||
])('should set `level` to `warning` for `%s`', (code) => {
|
||||
const error = new WorkflowActivationError(code, { cause });
|
||||
|
||||
expect(error.level).toBe('warning');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user