test: route cache in middleware/cache

This commit is contained in:
DIYgod
2019-02-01 17:52:29 +08:00
parent 5e43cdc355
commit b102ad2d07
3 changed files with 71 additions and 37 deletions

View File

@@ -86,35 +86,8 @@ router.get('/', async (ctx) => {
});
});
router.get('/test/:id', (ctx) => {
if (ctx.params.id === '0') {
throw Error('Error test');
}
const item = [];
if (ctx.params.id === 'long') {
item.push({
title: `Long Title `.repeat(10),
description: `Long Description `.repeat(10),
pubDate: new Date(`2018-3-1`).toUTCString(),
link: `https://github.com/DIYgod/RSSHub/issues/0`,
author: `DIYgod0`,
});
}
for (let i = 1; i < 6; i++) {
item.push({
title: `Title${i}`,
description: `Description${i}`,
pubDate: new Date(`2018-4-${i}`).toUTCString(),
link: `https://github.com/DIYgod/RSSHub/issues/${i}`,
author: `DIYgod${i}`,
});
}
ctx.state.data = {
title: `Test ${ctx.params.id}`,
link: 'https://github.com/DIYgod/RSSHub',
item: item,
};
});
// test
router.get('/test/:id', require('./routes/test'));
// RSSHub
router.get('/rsshub/rss', require('./routes/rsshub/rss'));