From 07c891caa65cd776e918c6bcdbc0acdbe4b15407 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Tue, 26 Mar 2024 01:15:06 +0800 Subject: [PATCH] feat: remove timeout test --- lib/utils/got.test.ts | 26 -------------------------- lib/utils/ofetch.ts | 2 +- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/lib/utils/got.test.ts b/lib/utils/got.test.ts index 3b3453a18d..45a1be6218 100644 --- a/lib/utils/got.test.ts +++ b/lib/utils/got.test.ts @@ -55,30 +55,4 @@ describe('got', () => { expect(response1.body).toBe('{"code": 0}'); expect(response1.data.code).toBe(0); }); - - it('timeout', async () => { - process.env.REQUEST_TIMEOUT = '500'; - - const { default: got } = await import('@/utils/got'); - nock('http://rsshub.test') - .get('/timeout') - .delay(600) - .reply(() => [200, '{"code": 0}']); - - const logger = (await import('@/utils/logger')).default; - // @ts-expect-error unused - const loggerSpy = vi.spyOn(logger, 'error').mockReturnValue({}); - - try { - await got.get('http://rsshub.test/timeout'); - throw new Error('Timeout Invalid'); - } catch (error: any) { - expect(error.name).toBe('FetchError'); - } - expect(loggerSpy).toHaveBeenCalledWith(expect.stringContaining('http://rsshub.test/timeout')); - - loggerSpy.mockRestore(); - - delete process.env.REQUEST_TIMEOUT; - }); }); diff --git a/lib/utils/ofetch.ts b/lib/utils/ofetch.ts index c02204862f..d7a765e119 100644 --- a/lib/utils/ofetch.ts +++ b/lib/utils/ofetch.ts @@ -10,7 +10,7 @@ const rofetch = ofetch.create({ 'user-agent': config.ua, }, onRequestError({ request, error }) { - logger.error(`Request ${request.url} fail: ${error}`); + logger.error(`Request ${request} fail: ${error}`); }, });