@@ -3,9 +3,12 @@ import { dirSync } from "tmp";
3
3
import { CancellationTokenSource } from "vscode-jsonrpc" ;
4
4
import type { RunQueryParams } from "../../../../src/query-server/messages" ;
5
5
import {
6
+ clearCache ,
6
7
QueryResultType ,
7
8
registerDatabases ,
8
9
runQuery ,
10
+ trimCache ,
11
+ trimCacheWithMode ,
9
12
} from "../../../../src/query-server/messages" ;
10
13
import type { CodeQLCliServer } from "../../../../src/codeql-cli/cli" ;
11
14
import type { BqrsCellValue } from "../../../../src/common/bqrs-cli-types" ;
@@ -198,5 +201,58 @@ describeWithCodeQL()("using the query server", () => {
198
201
) ;
199
202
}
200
203
} ) ;
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
+ } ) ;
201
257
}
202
258
} ) ;
0 commit comments