Skip to content

Commit d25d248

Browse files
committed
feat(chore): fix tests
1 parent cbc0718 commit d25d248

3 files changed

Lines changed: 8 additions & 11 deletions

File tree

src/__tests__/db-query/acceptance/dataset.controller.acceptance.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {DataSet} from '../../../components/db-query/models';
66
import {DataSetRepository} from '../../../components/db-query/repositories';
77
import {AiIntegrationBindings} from '../../../keys';
88
import {PermissionKey} from '../../../permissions';
9-
import {EmbeddingProvider, LLMProvider} from '../../../types';
9+
import {EmbeddingProvider} from '../../../types';
1010
import {TestApp} from '../../fixtures/test-app';
1111
import {buildToken, seedEmployees, setupApplication} from '../../test-helper';
1212

@@ -19,22 +19,14 @@ describe('DatasetController', () => {
1919
before('setupApplication', async () => {
2020
({app, client} = await setupApplication({
2121
noKnowledgeGraph: true,
22+
llmStub: sinon.stub(),
2223
}));
2324
llmStub = sinon.stub();
2425
llmStub.resolves([[0.1, 0.2, 0.3]]);
2526

2627
app.bind(AiIntegrationBindings.EmbeddingModel).to({
2728
embedDocuments: llmStub,
2829
} as unknown as EmbeddingProvider);
29-
app
30-
.bind(AiIntegrationBindings.SmartLLM)
31-
.to(llmStub as unknown as LLMProvider);
32-
app
33-
.bind(AiIntegrationBindings.CheapLLM)
34-
.to(llmStub as unknown as LLMProvider);
35-
app
36-
.bind(AiIntegrationBindings.FileLLM)
37-
.to(llmStub as unknown as LLMProvider);
3830
await seedEmployees(app);
3931
await seedDataset(app);
4032
});

src/__tests__/fixtures/test-app.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ export class TestApp extends BootMixin(
4444
this.bind(AiIntegrationBindings.CheapLLM).toProvider(Ollama);
4545
this.bind(AiIntegrationBindings.SmartLLM).toProvider(Ollama);
4646
this.bind(AiIntegrationBindings.FileLLM).toProvider(Ollama);
47-
} else {
47+
} else if (process.env.CEREBRAS === '1') {
4848
this.bind(AiIntegrationBindings.CheapLLM).toProvider(Cerebras);
4949
this.bind(AiIntegrationBindings.SmartLLM).toProvider(Cerebras);
5050
this.bind(AiIntegrationBindings.FileLLM).toProvider(Cerebras);
51+
} else if (options.llmStub) {
52+
this.bind(AiIntegrationBindings.CheapLLM).to(options.llmStub);
53+
this.bind(AiIntegrationBindings.SmartLLM).to(options.llmStub);
54+
this.bind(AiIntegrationBindings.FileLLM).to(options.llmStub);
5155
}
5256
this.bind(AiIntegrationBindings.EmbeddingModel).toProvider(OllamaEmbedding);
5357
this.bind('datasources.db').to(

src/__tests__/test-helper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ config();
2727

2828
export async function setupApplication(options: {
2929
noKnowledgeGraph?: boolean;
30+
llmStub?: sinon.SinonStub;
3031
}): Promise<AppWithClient> {
3132
const restConfig = givenHttpServerConfig({
3233
// Customize the server configuration here.

0 commit comments

Comments
 (0)