Files
Ncurator/tests/case/unit/knowledge/vector/embedding-error.test.ts
T
hy bb25b75058 Refactor runtime settings handling in tests
- Replace `runtimeSettingsOverride` with `streamingModeOverride` in multiple test files to streamline the configuration of LLM streaming modes.
- Update references to `aiRuntimeSettings` to use the new `appSettings` structure in relevant tests.
- Introduce new tests for workspace preparation and indexing to ensure sequential execution and proper handling of workspace jobs.
- Adjust SQLite migration tests to reflect changes in schema versioning and settings persistence.
- Modify system notification service tests to align with the updated app settings structure.
2026-09-20 12:22:32 +08:00

48 lines
1.9 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
EMBEDDING_INITIALIZATION_ERROR_MESSAGE,
VC_RUNTIME_ERROR_MESSAGE,
isVcRuntimeError,
toEmbeddingInitializationMessage
} from '../../../../../src/main/services/vector/embeddingError'
describe('embeddingError', () => {
it('recognizes VC++ runtime load failures', () => {
const messages = [
'A dynamic link library (DLL) initialization routine failed',
'DLL initialization routine failed',
'The specified module could not be found. dll load error',
'error 1114: A dynamic link library (DLL) initialization routine failed'
]
for (const message of messages) {
expect(isVcRuntimeError(new Error(message))).toBe(true)
}
})
it('matches VC++ runtime patterns case-insensitively', () => {
expect(isVcRuntimeError(new Error('A Dynamic Link Library (DLL) Initialization Routine Failed'))).toBe(true)
expect(isVcRuntimeError('Dynamic Link Library load failed')).toBe(true)
})
it('does not treat unrelated errors as VC++ runtime failures', () => {
expect(isVcRuntimeError(new Error('model unavailable'))).toBe(false)
expect(isVcRuntimeError(new Error('embedding runtime request timed out'))).toBe(false)
expect(isVcRuntimeError(null)).toBe(false)
expect(isVcRuntimeError(undefined)).toBe(false)
})
it('maps VC++ runtime failures to the runtime library message', () => {
expect(toEmbeddingInitializationMessage(new Error('dll initialization failed'))).toBe(
VC_RUNTIME_ERROR_MESSAGE
)
})
it('maps other failures to the generic initialization message', () => {
expect(toEmbeddingInitializationMessage(new Error('model unavailable'))).toBe(
EMBEDDING_INITIALIZATION_ERROR_MESSAGE
)
expect(toEmbeddingInitializationMessage('something else')).toBe(EMBEDDING_INITIALIZATION_ERROR_MESSAGE)
expect(toEmbeddingInitializationMessage(null)).toBe(EMBEDDING_INITIALIZATION_ERROR_MESSAGE)
})
})