test: correct test cases

This commit is contained in:
Louis 2024-10-22 17:09:24 +07:00
parent e8a9e8e28c
commit 9afbfd609a
No known key found for this signature in database
GPG Key ID: 44FA9F4D33C37DE2
4 changed files with 14 additions and 18 deletions

View File

@ -1,6 +1,5 @@
import { CORTEX_DEFAULT_PORT } from './consts'
import { NITRO_DEFAULT_PORT } from './consts'; it('should test CORTEX_DEFAULT_PORT', () => {
expect(CORTEX_DEFAULT_PORT).toBe(39291)
it('should test NITRO_DEFAULT_PORT', () => { })
expect(NITRO_DEFAULT_PORT).toBe(3928);
});

View File

@ -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' expect(startModel(modelId, settingParams)).resolves.toThrow()
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),
})
})
}) })
})

View File

@ -9,6 +9,7 @@ import { CORTEX_DEFAULT_PORT, LOCAL_HOST } from './consts'
*/ */
export const startModel = async (modelId: string, settingParams?: ModelSettingParams) => { export const startModel = async (modelId: string, settingParams?: ModelSettingParams) => {
return fetch(`http://${LOCAL_HOST}:${CORTEX_DEFAULT_PORT}/v1/models/start`, { return fetch(`http://${LOCAL_HOST}:${CORTEX_DEFAULT_PORT}/v1/models/start`, {
method: 'POST',
body: JSON.stringify({ model: modelId, ...settingParams }), body: JSON.stringify({ model: modelId, ...settingParams }),
}) })
} }
@ -18,6 +19,7 @@ export const startModel = async (modelId: string, settingParams?: ModelSettingPa
*/ */
export const stopModel = async (modelId: string) => { export const stopModel = async (modelId: string) => {
return fetch(`http://${LOCAL_HOST}:${CORTEX_DEFAULT_PORT}/v1/models/stop`, { return fetch(`http://${LOCAL_HOST}:${CORTEX_DEFAULT_PORT}/v1/models/stop`, {
method: 'POST',
body: JSON.stringify({ model: modelId }), body: JSON.stringify({ model: modelId }),
}) })
} }

View File

@ -31,6 +31,7 @@ describe('useModels', () => {
filter: () => models, filter: () => models,
}), }),
}), }),
get: () => undefined,
}, },
}) })