save to cache immediately so as not to fail tests

This commit is contained in:
Nate 2024-11-11 20:18:57 -08:00
parent d69f4d9c1e
commit f4159d2a2d
2 changed files with 23 additions and 28 deletions

View file

@ -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;

View file

@ -14,7 +14,7 @@ const filterTestCases = (tests: AutocompleteFileringTestInput[]) => {
return tests;
};
describe("llms/Mock", () => {
describe("Autocomplete filtering tests", () => {
beforeAll(async () => {
tearDownTestDir();
setUpTestDir();
@ -24,27 +24,25 @@ describe("llms/Mock", () => {
tearDownTestDir();
});
describe("Autocomplete Filtering Tests", () => {
beforeEach(async () => {
await new Promise((resolve) => setTimeout(resolve, 50));
});
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 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);
},
);
});
describe("Should return modified LLM output", () => {
it.each(filterTestCases(TEST_CASES_WITH_DIFF))(
"$description",
async (testCase) => {
await testAutocompleteFiltering(testCase);
},
);
});
});