diff --git a/packages/gen-ai-hub/test-util/mock-http.ts b/packages/gen-ai-hub/test-util/mock-http.ts deleted file mode 100644 index a4c96c4b..00000000 --- a/packages/gen-ai-hub/test-util/mock-http.ts +++ /dev/null @@ -1,52 +0,0 @@ -import fs from 'fs'; -import path from 'path'; -import { HttpDestination } from '@sap-cloud-sdk/connectivity'; -import nock from 'nock'; -import { - BaseLlmParameters, - CustomRequestConfig, - EndpointOptions -} from '../core/http-client.js'; - -const mockEndpoint: EndpointOptions = { - url: 'mock-endpoint', - apiVersion: 'mock-api-version' -}; - -export function mockInference( - request: { - data: D; - requestConfig?: CustomRequestConfig; - }, - response: { - data: any; - status?: number; - }, - destination: HttpDestination, - endpoint: EndpointOptions = mockEndpoint -): nock.Scope { - const { deploymentConfiguration, ...body } = request.data; - const { url, apiVersion } = endpoint; - - return nock(destination.url, { - reqheaders: { - 'ai-resource-group': 'default', - authorization: `Bearer ${destination.authTokens?.[0].value}` - } - }) - .post( - `/v2/inference/deployments/${deploymentConfiguration.deploymentId}/${url}`, - body as any - ) - .query(apiVersion ? { 'api-version': apiVersion } : {}) - .reply(response.status, response.data); -} - -export function parseMockResponse(client: string, fileName: string): T { - const fileContent = fs.readFileSync( - path.join('test-util', 'mock-data', client, fileName), - 'utf-8' - ); - - return JSON.parse(fileContent); -}