mirror of
https://git.boykissers.com/pawkey/pawkey-sk.git
synced 2025-12-20 12:14:18 +00:00
merge: Add "reject quotes" settings (!901)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/901 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
@@ -61,6 +61,7 @@ describe('NoteCreateService', () => {
|
||||
replyUserHost: null,
|
||||
renoteUserId: null,
|
||||
renoteUserHost: null,
|
||||
processErrors: [],
|
||||
};
|
||||
|
||||
const poll: IPoll = {
|
||||
|
||||
@@ -44,6 +44,7 @@ const base: MiNote = {
|
||||
replyUserHost: null,
|
||||
renoteUserId: null,
|
||||
renoteUserHost: null,
|
||||
processErrors: [],
|
||||
};
|
||||
|
||||
describe('misc:is-renote', () => {
|
||||
|
||||
73
packages/backend/test/unit/misc/is-retryable-error.ts
Normal file
73
packages/backend/test/unit/misc/is-retryable-error.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { UnrecoverableError } from 'bullmq';
|
||||
import { AbortError } from 'node-fetch';
|
||||
import { isRetryableError } from '@/misc/is-retryable-error.js';
|
||||
import { StatusError } from '@/misc/status-error.js';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
|
||||
describe(isRetryableError, () => {
|
||||
it('should return true for retryable StatusError', () => {
|
||||
const error = new StatusError('test error', 500);
|
||||
const result = isRetryableError(error);
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return false for permanent StatusError', () => {
|
||||
const error = new StatusError('test error', 400);
|
||||
const result = isRetryableError(error);
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return true for retryable IdentifiableError', () => {
|
||||
const error = new IdentifiableError('id', 'message', true);
|
||||
const result = isRetryableError(error);
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return false for permanent StatusError', () => {
|
||||
const error = new IdentifiableError('id', 'message', false);
|
||||
const result = isRetryableError(error);
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return false for UnrecoverableError', () => {
|
||||
const error = new UnrecoverableError();
|
||||
const result = isRetryableError(error);
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return true for typed AbortError', () => {
|
||||
const error = new AbortError();
|
||||
const result = isRetryableError(error);
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return true for named AbortError', () => {
|
||||
const error = new Error();
|
||||
error.name = 'AbortError';
|
||||
|
||||
const result = isRetryableError(error);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
const nonErrorInputs = [
|
||||
[null, 'null'],
|
||||
[undefined, 'undefined'],
|
||||
[0, 'number'],
|
||||
['string', 'string'],
|
||||
[true, 'boolean'],
|
||||
[[], 'array'],
|
||||
[{}, 'object'],
|
||||
];
|
||||
for (const [input, label] of nonErrorInputs) {
|
||||
it(`should return true for ${label} input`, () => {
|
||||
const result = isRetryableError(input);
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user