fix(test): mock $env/dynamic/private in llm-logging spec
Some checks failed
Build & Push Docker Image / test-and-build (push) Failing after 37s
Some checks failed
Build & Push Docker Image / test-and-build (push) Failing after 37s
Tests passed locally because .env provided OPENAI_BASE_URL and
OPENAI_API_KEY. In the Docker build stage there is no .env, so
createLLM() threw 'OPENAI_BASE_URL environment variable is not set'
before the mocked OpenAI client ever ran, causing 3 test failures.
Add vi.mock('$env/dynamic/private', ...) with stub values so the
tests are self-contained and environment-independent.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -13,6 +13,16 @@ vi.mock('openai', () => ({
|
||||
}
|
||||
}));
|
||||
|
||||
// Mock env so tests pass in environments without .env (e.g. Docker CI builds)
|
||||
vi.mock('$env/dynamic/private', () => ({
|
||||
env: {
|
||||
OPENAI_BASE_URL: 'http://localhost:11434/v1',
|
||||
OPENAI_API_KEY: 'test-key',
|
||||
LLM_MODEL: 'test-model',
|
||||
LLM_REQUEST_TIMEOUT_MS: undefined
|
||||
}
|
||||
}));
|
||||
|
||||
// Import AFTER mocking
|
||||
import { checkLLMHealth, checkModelAvailability } from '$lib/server/llm';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user