From 9afbfd609a17ffb1c19533e371d1bd9c63b62068 Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 22 Oct 2024 17:09:24 +0700 Subject: [PATCH] test: correct test cases --- .../node/api/restful/helper/consts.test.ts | 9 ++++----- .../api/restful/helper/startStopModel.test.ts | 20 +++++++------------ .../node/api/restful/helper/startStopModel.ts | 2 ++ web/hooks/useModels.test.ts | 1 + 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/core/src/node/api/restful/helper/consts.test.ts b/core/src/node/api/restful/helper/consts.test.ts index 34d42dcf0..524f0cbeb 100644 --- a/core/src/node/api/restful/helper/consts.test.ts +++ b/core/src/node/api/restful/helper/consts.test.ts @@ -1,6 +1,5 @@ +import { CORTEX_DEFAULT_PORT } from './consts' -import { NITRO_DEFAULT_PORT } from './consts'; - -it('should test NITRO_DEFAULT_PORT', () => { - expect(NITRO_DEFAULT_PORT).toBe(3928); -}); +it('should test CORTEX_DEFAULT_PORT', () => { + expect(CORTEX_DEFAULT_PORT).toBe(39291) +}) diff --git a/core/src/node/api/restful/helper/startStopModel.test.ts b/core/src/node/api/restful/helper/startStopModel.test.ts index a5475cc28..7c1a56cf1 100644 --- a/core/src/node/api/restful/helper/startStopModel.test.ts +++ b/core/src/node/api/restful/helper/startStopModel.test.ts @@ -1,16 +1,10 @@ +import { startModel } from './startStopModel' +describe('startModel', () => { + it('test_startModel_error', async () => { + const modelId = 'testModelId' + const settingParams = undefined - import { startModel } from './startStopModel' - - describe('startModel', () => { - it('test_startModel_error', async () => { - const modelId = 'testModelId' - const settingParams = undefined - - const result = await startModel(modelId, settingParams) - - expect(result).toEqual({ - error: expect.any(Error), - }) - }) + expect(startModel(modelId, settingParams)).resolves.toThrow() }) +}) diff --git a/core/src/node/api/restful/helper/startStopModel.ts b/core/src/node/api/restful/helper/startStopModel.ts index 857567612..2e9db6d15 100644 --- a/core/src/node/api/restful/helper/startStopModel.ts +++ b/core/src/node/api/restful/helper/startStopModel.ts @@ -9,6 +9,7 @@ import { CORTEX_DEFAULT_PORT, LOCAL_HOST } from './consts' */ export const startModel = async (modelId: string, settingParams?: ModelSettingParams) => { return fetch(`http://${LOCAL_HOST}:${CORTEX_DEFAULT_PORT}/v1/models/start`, { + method: 'POST', body: JSON.stringify({ model: modelId, ...settingParams }), }) } @@ -18,6 +19,7 @@ export const startModel = async (modelId: string, settingParams?: ModelSettingPa */ export const stopModel = async (modelId: string) => { return fetch(`http://${LOCAL_HOST}:${CORTEX_DEFAULT_PORT}/v1/models/stop`, { + method: 'POST', body: JSON.stringify({ model: modelId }), }) } diff --git a/web/hooks/useModels.test.ts b/web/hooks/useModels.test.ts index b58102144..2def2b745 100644 --- a/web/hooks/useModels.test.ts +++ b/web/hooks/useModels.test.ts @@ -31,6 +31,7 @@ describe('useModels', () => { filter: () => models, }), }), + get: () => undefined, }, })