test: fix caces
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import app from '@/app';
|
||||
import Parser from 'rss-parser';
|
||||
import { config } from '@/config';
|
||||
import nock from 'nock';
|
||||
|
||||
process.env.OPENAI_API_KEY = 'sk-1234567890';
|
||||
process.env.OPENAI_API_ENDPOINT = 'https://api.openai.mock/v1';
|
||||
|
||||
vi.mock('@/utils/request-rewriter', () => ({ default: null }));
|
||||
const { config } = await import('@/config');
|
||||
const { default: app } = await import('@/app');
|
||||
|
||||
const parser = new Parser();
|
||||
|
||||
@@ -424,26 +428,6 @@ describe('multi parameter', () => {
|
||||
|
||||
describe('openai', () => {
|
||||
it(`chatgpt`, async () => {
|
||||
vi.resetModules();
|
||||
|
||||
process.env.OPENAI_API_KEY = 'sk-1234567890';
|
||||
const app = (await import('@/app')).default;
|
||||
const { config } = await import('@/config');
|
||||
nock(config.openai.endpoint)
|
||||
.post('/chat/completions')
|
||||
.reply(() => [
|
||||
200,
|
||||
{
|
||||
choices: [
|
||||
{
|
||||
message: {
|
||||
content: 'Summary of the article.',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
const responseWithGpt = await app.request('/test/gpt?chatgpt=true');
|
||||
const responseNormal = await app.request('/test/gpt');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user