@@ -108,8 +108,6 @@ describe("CodeIndexServiceFactory", () => {
108108 const requiredSettings = [
109109 [ "openai" , "openAiOptions" , "openAiNativeApiKey" , "openAiConfigMissing" ] ,
110110 [ "ollama" , "ollamaOptions" , "ollamaBaseUrl" , "ollamaConfigMissing" ] ,
111- [ "openai-compatible" , "openAiCompatibleOptions" , "baseUrl" , "openAiCompatibleConfigMissing" ] ,
112- [ "openai-compatible" , "openAiCompatibleOptions" , "apiKey" , "openAiCompatibleConfigMissing" ] ,
113111 [ "gemini" , "geminiOptions" , "apiKey" , "geminiConfigMissing" ] ,
114112 [ "mistral" , "mistralOptions" , "apiKey" , "mistralConfigMissing" ] ,
115113 [ "vercel-ai-gateway" , "vercelAiGatewayOptions" , "apiKey" , "vercelAiGatewayConfigMissing" ] ,
@@ -352,40 +350,36 @@ describe("CodeIndexServiceFactory", () => {
352350 )
353351 } )
354352
355- it ( "should throw error when OpenAI Compatible base URL is missing ", ( ) => {
353+ it . each ( [ undefined , "" ] ) ( "rejects missing or empty OpenAI Compatible base URL: %s ", ( baseUrl ) => {
356354 // Arrange
357355 const testConfig = {
358356 embedderProvider : "openai-compatible" ,
359357 modelId : "text-embedding-3-large" ,
360358 openAiCompatibleOptions : {
361- baseUrl : undefined ,
359+ baseUrl,
362360 apiKey : "test-api-key" ,
363361 } ,
364362 }
365363 mockConfigManager . getConfig . mockReturnValue ( testConfig as any )
366364
367365 // Act & Assert
368- expect ( ( ) => embedderFactory . create ( mockConfigManager . getConfig ( ) ) ) . toThrow (
369- "serviceFactory.openAiCompatibleConfigMissing" ,
370- )
366+ expect ( ( ) => embedderFactory . create ( mockConfigManager . getConfig ( ) ) ) . toThrow ( "validation.baseUrlRequired" )
371367 } )
372368
373- it ( "should throw error when OpenAI Compatible API key is missing ", ( ) => {
369+ it . each ( [ undefined , "" ] ) ( "rejects missing or empty OpenAI Compatible API key: %s ", ( apiKey ) => {
374370 // Arrange
375371 const testConfig = {
376372 embedderProvider : "openai-compatible" ,
377373 modelId : "text-embedding-3-large" ,
378374 openAiCompatibleOptions : {
379375 baseUrl : "https://api.example.com/v1" ,
380- apiKey : undefined ,
376+ apiKey,
381377 } ,
382378 }
383379 mockConfigManager . getConfig . mockReturnValue ( testConfig as any )
384380
385381 // Act & Assert
386- expect ( ( ) => embedderFactory . create ( mockConfigManager . getConfig ( ) ) ) . toThrow (
387- "serviceFactory.openAiCompatibleConfigMissing" ,
388- )
382+ expect ( ( ) => embedderFactory . create ( mockConfigManager . getConfig ( ) ) ) . toThrow ( "validation.apiKeyRequired" )
389383 } )
390384
391385 it ( "should throw error when OpenAI Compatible options are missing" , ( ) => {
@@ -398,9 +392,7 @@ describe("CodeIndexServiceFactory", () => {
398392 mockConfigManager . getConfig . mockReturnValue ( testConfig as any )
399393
400394 // Act & Assert
401- expect ( ( ) => embedderFactory . create ( mockConfigManager . getConfig ( ) ) ) . toThrow (
402- "serviceFactory.openAiCompatibleConfigMissing" ,
403- )
395+ expect ( ( ) => embedderFactory . create ( mockConfigManager . getConfig ( ) ) ) . toThrow ( "validation.baseUrlRequired" )
404396 } )
405397
406398 it ( "should create GeminiEmbedder with default model when no modelId specified" , ( ) => {
0 commit comments