feat: split test routes
This commit is contained in:
parent
e3f57a17e0
commit
c265a0616a
|
|
@ -0,0 +1,22 @@
|
|||
import { Route } from '@/types';
|
||||
import ConfigNotFoundError from '@/errors/types/config-not-found';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/config-not-found-error',
|
||||
name: 'config-not-found-error',
|
||||
maintainers: ['DIYgod'],
|
||||
example: '/config-not-found-error',
|
||||
handler,
|
||||
};
|
||||
|
||||
function handler() {
|
||||
throw new ConfigNotFoundError('Test config not found error');
|
||||
return {
|
||||
title: 'Title',
|
||||
items: [
|
||||
{
|
||||
title: 'Title',
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import { Route } from '@/types';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/error',
|
||||
name: 'error',
|
||||
maintainers: ['DIYgod'],
|
||||
example: '/error',
|
||||
handler,
|
||||
};
|
||||
|
||||
function handler() {
|
||||
throw new Error('Error test');
|
||||
return {
|
||||
title: 'Title',
|
||||
items: [
|
||||
{
|
||||
title: 'Title',
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/httperror',
|
||||
name: 'httperror',
|
||||
maintainers: ['DIYgod'],
|
||||
example: '/httperror',
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler() {
|
||||
await got({
|
||||
method: 'get',
|
||||
url: 'https://httpbingo.org/status/404',
|
||||
});
|
||||
return {
|
||||
title: 'Title',
|
||||
items: [
|
||||
{
|
||||
title: 'Title',
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
|
@ -1,37 +1,20 @@
|
|||
import { Route, DataItem } from '@/types';
|
||||
import { config } from '@/config';
|
||||
import got from '@/utils/got';
|
||||
import wait from '@/utils/wait';
|
||||
import cache from '@/utils/cache';
|
||||
import { fetchArticle } from '@/utils/wechat-mp';
|
||||
import ConfigNotFoundError from '@/errors/types/config-not-found';
|
||||
import InvalidParameterError from '@/errors/types/invalid-parameter';
|
||||
|
||||
let cacheIndex = 0;
|
||||
|
||||
export const route: Route = {
|
||||
path: '/:id/:params?',
|
||||
name: 'Unknown',
|
||||
name: 'Test',
|
||||
maintainers: ['DIYgod', 'NeverBehave'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
if (ctx.req.param('id') === 'error') {
|
||||
throw new Error('Error test');
|
||||
}
|
||||
if (ctx.req.param('id') === 'httperror') {
|
||||
await got({
|
||||
method: 'get',
|
||||
url: 'https://httpbingo.org/status/404',
|
||||
});
|
||||
}
|
||||
if (ctx.req.param('id') === 'config-not-found-error') {
|
||||
throw new ConfigNotFoundError('Test config not found error');
|
||||
}
|
||||
if (ctx.req.param('id') === 'invalid-parameter-error') {
|
||||
throw new InvalidParameterError('Test invalid parameter error');
|
||||
}
|
||||
let item: DataItem[] = [];
|
||||
switch (ctx.req.param('id')) {
|
||||
case 'filter':
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
import { Route } from '@/types';
|
||||
import InvalidParameterError from '@/errors/types/invalid-parameter';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/invalid-parameter-error',
|
||||
name: 'invalid-parameter-error',
|
||||
maintainers: ['DIYgod'],
|
||||
example: '/invalid-parameter-error',
|
||||
handler,
|
||||
};
|
||||
|
||||
function handler() {
|
||||
throw new InvalidParameterError('Test invalid parameter error');
|
||||
return {
|
||||
title: 'Title',
|
||||
items: [
|
||||
{
|
||||
title: 'Title',
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: 'Unknown',
|
||||
name: 'RSSHub Test',
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue