@@ -3,9 +3,12 @@ import { dirSync } from "tmp";
33import { CancellationTokenSource } from "vscode-jsonrpc" ;
44import type { RunQueryParams } from "../../../../src/query-server/messages" ;
55import {
6+ clearCache ,
67 QueryResultType ,
78 registerDatabases ,
89 runQuery ,
10+ trimCache ,
11+ trimCacheWithMode ,
912} from "../../../../src/query-server/messages" ;
1013import type { CodeQLCliServer } from "../../../../src/codeql-cli/cli" ;
1114import type { BqrsCellValue } from "../../../../src/common/bqrs-cli-types" ;
@@ -198,5 +201,58 @@ describeWithCodeQL()("using the query server", () => {
198201 ) ;
199202 }
200203 } ) ;
204+
205+ it ( "should invoke codeQL.trimOverlayBaseCache command when queryServerTrimCacheWithMode is enabled" , async ( ) => {
206+ const features = ( await cliServer . getFeatures ( ) ) as {
207+ [ feature : string ] : boolean | undefined ;
208+ } ;
209+
210+ // Register the database first (if not already done)
211+ await qs . sendRequest ( registerDatabases , { databases : [ db ] } ) ;
212+
213+ try {
214+ // Send the trimCacheWithMode request
215+ const params = {
216+ db,
217+ mode : "overlay" ,
218+ } ;
219+ const result = await qs . sendRequest (
220+ trimCacheWithMode ,
221+ params ,
222+ token ,
223+ ( ) => { } ,
224+ ) ;
225+
226+ // The result should contain a deletionMessage string
227+ expect ( result ) . toHaveProperty ( "deletionMessage" ) ;
228+ expect ( typeof result . deletionMessage ) . toBe ( "string" ) ;
229+ expect ( features . queryServerTrimCacheWithMode ) . toBeTruthy ( ) ;
230+ } catch ( e ) {
231+ expect ( features . queryServerTrimCacheWithMode ) . toBeFalsy ( ) ;
232+ expect ( ( e as Error ) . message ) . toContain (
233+ "Unsupported request method: evaluation/trimCacheWithMode" ,
234+ ) ;
235+ }
236+ } ) ;
237+
238+ it ( "should invoke trimCache command and receive a deletionMessage" , async ( ) => {
239+ // Register the database first (if not already done)
240+ await qs . sendRequest ( registerDatabases , { databases : [ db ] } ) ;
241+
242+ const params = { db } ;
243+ const result = await qs . sendRequest ( trimCache , params , token , ( ) => { } ) ;
244+ expect ( result ) . toHaveProperty ( "deletionMessage" ) ;
245+ expect ( typeof result . deletionMessage ) . toBe ( "string" ) ;
246+ } ) ;
247+
248+ it ( "should invoke clearCache command and receive a deletionMessage" , async ( ) => {
249+ // Register the database first (if not already done)
250+ await qs . sendRequest ( registerDatabases , { databases : [ db ] } ) ;
251+
252+ const params = { db, dryRun : false } ;
253+ const result = await qs . sendRequest ( clearCache , params , token , ( ) => { } ) ;
254+ expect ( result ) . toHaveProperty ( "deletionMessage" ) ;
255+ expect ( typeof result . deletionMessage ) . toBe ( "string" ) ;
256+ } ) ;
201257 }
202258} ) ;
0 commit comments