@@ -90,7 +90,7 @@ describe('getMemoizedKeyValueStoreBackedByRegionalBlobStore', () => {
9090const store = getMemoizedKeyValueStoreBackedByRegionalBlobStore ( )
9191const get1 = await store . get ( TEST_KEY , OTEL_SPAN_TITLE )
9292
93- expect ( mockedStore . getWithMetadata , 'Blobs should be requested' ) . toHaveBeenCalledTimes ( 1 )
93+ expect ( mockedStore . getWithMetadata , 'Blobs should be requested' ) . toHaveBeenCalledOnce ( )
9494expect ( get1 , 'Expected blob should be returned' ) . toBe ( TEST_DEFAULT_VALUE )
9595
9696const get2 = await store . get ( TEST_KEY , OTEL_SPAN_TITLE )
@@ -103,14 +103,14 @@ describe('getMemoizedKeyValueStoreBackedByRegionalBlobStore', () => {
103103const store = getMemoizedKeyValueStoreBackedByRegionalBlobStore ( )
104104
105105const get1 = await store . get ( TEST_KEY , OTEL_SPAN_TITLE )
106- expect ( mockedStore . getWithMetadata , 'Blobs should be requested' ) . toHaveBeenCalledTimes ( 1 )
106+ expect ( mockedStore . getWithMetadata , 'Blobs should be requested' ) . toHaveBeenCalledOnce ( )
107107expect ( get1 , 'Expected blob should be returned' ) . toBe ( TEST_DEFAULT_VALUE )
108108
109109const get2 = await store . get ( TEST_KEY , OTEL_SPAN_TITLE )
110110expect (
111111mockedStore . getWithMetadata ,
112112'Blobs should be requested just once' ,
113- ) . toHaveBeenCalledTimes ( 1 )
113+ ) . toHaveBeenCalledOnce ( )
114114expect ( get2 , 'Expected second .get to return the same as first one' ) . toBe ( get1 )
115115} )
116116} )
@@ -126,12 +126,10 @@ describe('getMemoizedKeyValueStoreBackedByRegionalBlobStore', () => {
126126
127127await store . set ( TEST_KEY , writeValue , OTEL_SPAN_TITLE )
128128
129- expect ( mockedStore . setJSON , 'Blobs should be posted' ) . toHaveBeenCalledTimes ( 1 )
129+ expect ( mockedStore . setJSON , 'Blobs should be posted' ) . toHaveBeenCalledOnce ( )
130130
131131const get = await store . get ( TEST_KEY , OTEL_SPAN_TITLE )
132- expect ( mockedStore . getWithMetadata , 'Value should be read from memory' ) . toHaveBeenCalledTimes (
133- 0 ,
134- )
132+ expect ( mockedStore . getWithMetadata , 'Value should be read from memory' ) . not . toHaveBeenCalled ( )
135133expect ( get , 'Value from memory should be correct' ) . toBe ( writeValue )
136134} )
137135} )
@@ -213,16 +211,14 @@ describe('getMemoizedKeyValueStoreBackedByRegionalBlobStore', () => {
213211await runWithRequestContext ( requestContext1 , async ( ) => {
214212const get = await store . get ( TEST_KEY , OTEL_SPAN_TITLE )
215213expect ( get , 'Value from memory should be the same as before' ) . toBe ( TEST_DEFAULT_VALUE )
216- expect ( mockedStore . getWithMetadata , 'Blobs should be requested' ) . toHaveBeenCalledTimes ( 1 )
214+ expect ( mockedStore . getWithMetadata , 'Blobs should be requested' ) . toHaveBeenCalledOnce ( )
217215} )
218216
219217await runWithRequestContext ( requestContext2 , async ( ) => {
220218mockedStore . getWithMetadata . mockClear ( )
221219await store . set ( TEST_KEY , writeValue , OTEL_SPAN_TITLE )
222220const get = await store . get ( TEST_KEY , OTEL_SPAN_TITLE )
223- expect ( mockedStore . getWithMetadata , 'Value should be read from memory' ) . toHaveBeenCalledTimes (
224- 0 ,
225- )
221+ expect ( mockedStore . getWithMetadata , 'Value should be read from memory' ) . not . toHaveBeenCalled ( )
226222expect ( get , 'Value from memory should be correct' ) . toBe ( writeValue )
227223} )
228224
@@ -233,9 +229,7 @@ describe('getMemoizedKeyValueStoreBackedByRegionalBlobStore', () => {
233229get ,
234230'Value from memory should be the same as before and not affected by other request context' ,
235231) . toBe ( TEST_DEFAULT_VALUE )
236- expect ( mockedStore . getWithMetadata , 'Value should be read from memory' ) . toHaveBeenCalledTimes (
237- 0 ,
238- )
232+ expect ( mockedStore . getWithMetadata , 'Value should be read from memory' ) . not . toHaveBeenCalled ( )
239233} )
240234} )
241235
@@ -253,65 +247,51 @@ describe('getMemoizedKeyValueStoreBackedByRegionalBlobStore', () => {
253247
254248await runWithRequestContext ( requestContext1 , async ( ) => {
255249await store . get ( 'heavy-route-1' , OTEL_SPAN_TITLE )
256- expect ( mockedStore . getWithMetadata , 'Value should be read from blobs' ) . toHaveBeenCalledTimes (
257- 1 ,
258- )
250+ expect ( mockedStore . getWithMetadata , 'Value should be read from blobs' ) . toHaveBeenCalledOnce ( )
259251mockedStore . getWithMetadata . mockClear ( )
260252
261253await store . get ( 'heavy-route-1' , OTEL_SPAN_TITLE )
262- expect ( mockedStore . getWithMetadata , 'Value should be read from memory' ) . toHaveBeenCalledTimes (
263- 0 ,
264- )
254+ expect ( mockedStore . getWithMetadata , 'Value should be read from memory' ) . not . toHaveBeenCalled ( )
265255mockedStore . getWithMetadata . mockClear ( )
266256
267257await store . get ( 'heavy-route-2' , OTEL_SPAN_TITLE )
268- expect ( mockedStore . getWithMetadata , 'Value should be read from blobs' ) . toHaveBeenCalledTimes (
269- 1 ,
270- )
258+ expect ( mockedStore . getWithMetadata , 'Value should be read from blobs' ) . toHaveBeenCalledOnce ( )
271259mockedStore . getWithMetadata . mockClear ( )
272260
273261// at this point we should exceed the memory limit and least recently used value should be evicted
274262await store . get ( 'heavy-route-1' , OTEL_SPAN_TITLE )
275263expect (
276264mockedStore . getWithMetadata ,
277265'Previously stored in-memory value should be evicted and fresh value should be read from blobs' ,
278- ) . toHaveBeenCalledTimes ( 1 )
266+ ) . toHaveBeenCalledOnce ( )
279267mockedStore . getWithMetadata . mockClear ( )
280268
281269await store . get ( 'heavy-route-1' , OTEL_SPAN_TITLE )
282270expect (
283271mockedStore . getWithMetadata ,
284272'Value should be read from memory again' ,
285- ) . toHaveBeenCalledTimes ( 0 )
273+ ) . not . toHaveBeenCalled ( )
286274mockedStore . getWithMetadata . mockClear ( )
287275} )
288276
289277await runWithRequestContext ( requestContext2 , async ( ) => {
290278await store . get ( 'heavy-route-1' , OTEL_SPAN_TITLE )
291- expect ( mockedStore . getWithMetadata , 'Value should be read from blobs' ) . toHaveBeenCalledTimes (
292- 1 ,
293- )
279+ expect ( mockedStore . getWithMetadata , 'Value should be read from blobs' ) . toHaveBeenCalledOnce ( )
294280mockedStore . getWithMetadata . mockClear ( )
295281
296282await store . get ( 'heavy-route-1' , OTEL_SPAN_TITLE )
297- expect ( mockedStore . getWithMetadata , 'Value should be read from memory' ) . toHaveBeenCalledTimes (
298- 0 ,
299- )
283+ expect ( mockedStore . getWithMetadata , 'Value should be read from memory' ) . not . toHaveBeenCalled ( )
300284mockedStore . getWithMetadata . mockClear ( )
301285} )
302286
303287await runWithRequestContext ( requestContext1 , async ( ) => {
304288await store . get ( 'heavy-route-1' , OTEL_SPAN_TITLE )
305289// operations in requestContext2 should result in evicting value for requestContext1
306- expect ( mockedStore . getWithMetadata , 'Value should be read from blobs' ) . toHaveBeenCalledTimes (
307- 1 ,
308- )
290+ expect ( mockedStore . getWithMetadata , 'Value should be read from blobs' ) . toHaveBeenCalledOnce ( )
309291mockedStore . getWithMetadata . mockClear ( )
310292
311293await store . get ( 'heavy-route-1' , OTEL_SPAN_TITLE )
312- expect ( mockedStore . getWithMetadata , 'Value should be read from memory' ) . toHaveBeenCalledTimes (
313- 0 ,
314- )
294+ expect ( mockedStore . getWithMetadata , 'Value should be read from memory' ) . not . toHaveBeenCalled ( )
315295mockedStore . getWithMetadata . mockClear ( )
316296} )
317297} )