@@ -237,15 +237,17 @@ test("downloadDependencyCaches - does not restore caches with feature keys if no
237237 . resolves ( CSHARP_BASE_PATTERNS ) ;
238238 makePatternCheckStub . withArgs ( CSHARP_EXTRA_PATTERNS ) . resolves ( undefined ) ;
239239
240- const results = await downloadDependencyCaches (
240+ const result = await downloadDependencyCaches (
241241 codeql ,
242242 createFeatures ( [ ] ) ,
243243 [ KnownLanguage . csharp ] ,
244244 logger ,
245245 ) ;
246- t . is ( results . length , 1 ) ;
247- t . is ( results [ 0 ] . language , KnownLanguage . csharp ) ;
248- t . is ( results [ 0 ] . hit_kind , CacheHitKind . Miss ) ;
246+ const statusReport = result . statusReport ;
247+ t . is ( statusReport . length , 1 ) ;
248+ t . is ( statusReport [ 0 ] . language , KnownLanguage . csharp ) ;
249+ t . is ( statusReport [ 0 ] . hit_kind , CacheHitKind . Miss ) ;
250+ t . deepEqual ( result . exactKeys , [ ] ) ;
249251 t . assert ( restoreCacheStub . calledOnce ) ;
250252} ) ;
251253
@@ -257,7 +259,8 @@ test("downloadDependencyCaches - restores caches with feature keys if features a
257259 const logger = getRecordingLogger ( messages ) ;
258260 const features = createFeatures ( [ Feature . CsharpNewCacheKey ] ) ;
259261
260- sinon . stub ( glob , "hashFiles" ) . resolves ( "abcdef" ) ;
262+ const mockHash = "abcdef" ;
263+ sinon . stub ( glob , "hashFiles" ) . resolves ( mockHash ) ;
261264
262265 const keyWithFeature = await cacheKey (
263266 codeql ,
@@ -277,15 +280,28 @@ test("downloadDependencyCaches - restores caches with feature keys if features a
277280 . resolves ( CSHARP_BASE_PATTERNS ) ;
278281 makePatternCheckStub . withArgs ( CSHARP_EXTRA_PATTERNS ) . resolves ( undefined ) ;
279282
280- const results = await downloadDependencyCaches (
283+ const result = await downloadDependencyCaches (
281284 codeql ,
282285 features ,
283286 [ KnownLanguage . csharp ] ,
284287 logger ,
285288 ) ;
286- t . is ( results . length , 1 ) ;
287- t . is ( results [ 0 ] . language , KnownLanguage . csharp ) ;
288- t . is ( results [ 0 ] . hit_kind , CacheHitKind . Exact ) ;
289+
290+ // Check that the status report for telemetry indicates that one cache was restored with an exact match.
291+ const statusReport = result . statusReport ;
292+ t . is ( statusReport . length , 1 ) ;
293+ t . is ( statusReport [ 0 ] . language , KnownLanguage . csharp ) ;
294+ t . is ( statusReport [ 0 ] . hit_kind , CacheHitKind . Exact ) ;
295+
296+ // Check that the exact key match has been returned.
297+ const exactKeys = result . exactKeys ;
298+ t . is ( exactKeys . length , 1 ) ;
299+ t . assert (
300+ exactKeys [ 0 ] . endsWith ( mockHash ) ,
301+ "Expected exact key match to end with hash returned by `hashFiles`" ,
302+ ) ;
303+
304+ // `restoreCache` should have been called exactly once.
289305 t . assert ( restoreCacheStub . calledOnce ) ;
290306} ) ;
291307
@@ -319,15 +335,17 @@ test("downloadDependencyCaches - restores caches with feature keys if features a
319335 . resolves ( CSHARP_BASE_PATTERNS ) ;
320336 makePatternCheckStub . withArgs ( CSHARP_EXTRA_PATTERNS ) . resolves ( undefined ) ;
321337
322- const results = await downloadDependencyCaches (
338+ const result = await downloadDependencyCaches (
323339 codeql ,
324340 features ,
325341 [ KnownLanguage . csharp ] ,
326342 logger ,
327343 ) ;
328- t . is ( results . length , 1 ) ;
329- t . is ( results [ 0 ] . language , KnownLanguage . csharp ) ;
330- t . is ( results [ 0 ] . hit_kind , CacheHitKind . Partial ) ;
344+ const statusReport = result . statusReport ;
345+ t . is ( statusReport . length , 1 ) ;
346+ t . is ( statusReport [ 0 ] . language , KnownLanguage . csharp ) ;
347+ t . is ( statusReport [ 0 ] . hit_kind , CacheHitKind . Partial ) ;
348+ t . deepEqual ( result . exactKeys , [ ] ) ;
331349 t . assert ( restoreCacheStub . calledOnce ) ;
332350} ) ;
333351
0 commit comments