Repository navigation
First-run fixes: OPENAI_BASE_URL and CLI entrypoint regression test #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
d162ddc
1d76560
4f9867d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||||||
| import { afterEach, describe, expect, it, vi } from 'vitest'; | ||||||||||
|
|
||||||||||
| describe('DEFAULT_EMBEDDING_CONFIG environment', () => { | ||||||||||
| afterEach(() => { | ||||||||||
| vi.unstubAllEnvs(); | ||||||||||
| vi.resetModules(); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| it('uses OPENAI_BASE_URL when set', async () => { | ||||||||||
| vi.stubEnv('OPENAI_BASE_URL', 'http://127.0.0.1:11434/v1/'); | ||||||||||
| const { DEFAULT_EMBEDDING_CONFIG } = await import('../src/embeddings/types.js'); | ||||||||||
| expect(DEFAULT_EMBEDDING_CONFIG.apiEndpoint).toBe('http://127.0.0.1:11434/v1'); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| it('defaults to the official OpenAI endpoint when OPENAI_BASE_URL is unset', async () => { | ||||||||||
| vi.unstubAllEnvs(); | ||||||||||
| const { DEFAULT_EMBEDDING_CONFIG } = await import('../src/embeddings/types.js'); | ||||||||||
|
Comment on lines
+16
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| expect(DEFAULT_EMBEDDING_CONFIG.apiEndpoint).toBe('https://api.openai.com/v1'); | ||||||||||
| }); | ||||||||||
| }); | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { afterEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| describe('getEmbeddingProvider cache key', () => { | ||
| afterEach(() => { | ||
| vi.resetModules(); | ||
| vi.doUnmock('../src/embeddings/openai.js'); | ||
| }); | ||
|
|
||
| it('rebuilds the OpenAI provider when apiEndpoint changes', async () => { | ||
| const endpoints: string[] = []; | ||
| vi.doMock('../src/embeddings/openai.js', () => ({ | ||
| OpenAIEmbeddingProvider: class { | ||
| constructor(_model: string, _apiKey?: string, apiEndpoint?: string) { | ||
| endpoints.push(apiEndpoint ?? ''); | ||
| } | ||
|
|
||
| async initialize(): Promise<void> { | ||
| return undefined; | ||
| } | ||
| } | ||
| })); | ||
|
|
||
| const { getEmbeddingProvider } = await import('../src/embeddings/index.js'); | ||
| await getEmbeddingProvider({ | ||
| provider: 'openai', | ||
| model: 'text-embedding-3-small', | ||
| apiKey: 'sk-test', | ||
| apiEndpoint: 'http://127.0.0.1:11434/v1' | ||
| }); | ||
| await getEmbeddingProvider({ | ||
| provider: 'openai', | ||
| model: 'text-embedding-3-small', | ||
| apiKey: 'sk-test', | ||
| apiEndpoint: 'http://127.0.0.1:8080/v1' | ||
| }); | ||
|
|
||
| expect(endpoints).toEqual(['http://127.0.0.1:11434/v1', 'http://127.0.0.1:8080/v1']); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a Windows contributor lacks permission to create symlinks,
symlinkSyncthrows before this test reaches its cleanup block. The suite fails and leaves both temporary directories behind. Use the same Windows skip guard as the symlink test immediately below, and clean up both directories when setup fails.