Skip to content

Commit

Permalink
Merge pull request #2882 from continuedev/nate/tests
Browse files Browse the repository at this point in the history
save to cache immediately so as not to fail tests
  • Loading branch information
sestinj authored Nov 12, 2024
2 parents d69f4d9 + f4159d2 commit d2fa937
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 30 deletions.
11 changes: 4 additions & 7 deletions core/autocomplete/CompletionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,10 @@ export class CompletionProvider {

//////////

// Do some stuff later so as not to block return. Latency matters
const completionToCache = outcome.completion;
setTimeout(async () => {
if (!outcome.cacheHit) {
(await this.autocompleteCache).put(outcome.prefix, completionToCache);
}
}, 100);
// Save to cache
if (!outcome.cacheHit) {
(await this.autocompleteCache).put(outcome.prefix, outcome.completion);
}

// When using the JetBrains extension, Mark as displayed
const ideType = (await this.ide.getIdeInfo()).ideType;
Expand Down
44 changes: 21 additions & 23 deletions core/autocomplete/filtering/test/filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const filterTestCases = (tests: AutocompleteFileringTestInput[]) => {
return tests;
};

describe("llms/Mock", () => {
describe("Autocomplete filtering tests", () => {
beforeAll(async () => {
tearDownTestDir();
setUpTestDir();
Expand All @@ -24,27 +24,25 @@ describe("llms/Mock", () => {
tearDownTestDir();
});

describe("Autocomplete Filtering Tests", () => {
beforeEach(async () => {
await new Promise((resolve) => setTimeout(resolve, 50));
});

describe("Should return unmodified LLM output", () => {
it.each(filterTestCases(TEST_CASES_WITHOUT_DIFF))(
"$description",
async (testCase) => {
await testAutocompleteFiltering(testCase);
},
);
});

describe("Should return modified LLM output", () => {
it.each(filterTestCases(TEST_CASES_WITH_DIFF))(
"$description",
async (testCase) => {
await testAutocompleteFiltering(testCase);
},
);
});
beforeEach(async () => {
await new Promise((resolve) => setTimeout(resolve, 50));
});

describe("Should return unmodified LLM output", () => {
it.each(filterTestCases(TEST_CASES_WITHOUT_DIFF))(
"$description",
async (testCase) => {
await testAutocompleteFiltering(testCase);
},
);
});

describe("Should return modified LLM output", () => {
it.each(filterTestCases(TEST_CASES_WITH_DIFF))(
"$description",
async (testCase) => {
await testAutocompleteFiltering(testCase);
},
);
});
});

0 comments on commit d2fa937

Please sign in to comment.