@@ -41,11 +41,11 @@ Deno.test('adapter', async (t) => {
4141 } )
4242
4343 assertObjectMatch ( scan . calls [ 0 ] . args , [ 0 , {
44- pattern : 'word_ *' ,
44+ pattern : '{word}_ *' ,
4545 count : 100 ,
4646 } ] )
4747 assertObjectMatch ( scan . calls [ 1 ] . args , [ '50' , {
48- pattern : 'word_ *' ,
48+ pattern : '{word}_ *' ,
4949 count : 100 ,
5050 } ] )
5151 assert ( results . docs . length === 100 )
@@ -122,14 +122,14 @@ Deno.test('adapter', async (t) => {
122122 const adapter = createAdapter ( {
123123 ...baseStubClient ,
124124 del,
125- scan : resolves ( [ '0' , [ 'baz ' , 'bar ' ] ] ) ,
125+ scan : resolves ( [ '0' , [ '{foo}_baz ' , '{foo}_bar ' ] ] ) ,
126126 } , baseOptions )
127127
128128 const result = await adapter . destroyStore ( 'foo' )
129129
130130 assert ( result . ok )
131- assertObjectMatch ( del . calls [ 0 ] , { args : [ 'baz ' ] } )
132- assertObjectMatch ( del . calls [ 1 ] , { args : [ 'bar ' ] } )
131+ assertObjectMatch ( del . calls [ 0 ] , { args : [ '{foo}_baz ' ] } )
132+ assertObjectMatch ( del . calls [ 1 ] , { args : [ '{foo}_bar ' ] } )
133133 assertObjectMatch ( del . calls [ 2 ] , { args : [ 'store_foo' ] } )
134134 } ,
135135 )
@@ -139,7 +139,8 @@ Deno.test('adapter', async (t) => {
139139 await t . step ( 'should save the doc in redis as serialized JSON' , async ( ) => {
140140 const adapter = createAdapter ( {
141141 ...baseStubClient ,
142- set : ( _k , v , opts ) => {
142+ set : ( k , v , opts ) => {
143+ assertEquals ( k , '{foo}_bar' )
143144 assertEquals ( v , JSON . stringify ( { bam : 'baz' } ) )
144145 assertObjectMatch ( opts , { px : 5000 } )
145146 return Promise . resolve ( 'OK' )
@@ -229,7 +230,11 @@ Deno.test('adapter', async (t) => {
229230 const adapter = createAdapter ( {
230231 ...baseStubClient ,
231232 // serialized JSON
232- get : resolves ( JSON . stringify ( value ) ) ,
233+ get : ( k ) => {
234+ return k === 'store_foo'
235+ ? Promise . resolve ( JSON . stringify ( { active : true } ) ) // store
236+ : ( assertEquals ( k , '{foo}_bar' ) , Promise . resolve ( JSON . stringify ( value ) ) )
237+ } ,
233238 } , baseOptions )
234239
235240 const result = await adapter . getDoc ( {
@@ -266,12 +271,16 @@ Deno.test('adapter', async (t) => {
266271 await t . step ( 'should upsert the doc into Redis as serialized JSON' , async ( ) => {
267272 const adapter = createAdapter ( {
268273 ...baseStubClient ,
269- set : ( _k , v , opts ) => {
274+ set : ( k , v , opts ) => {
275+ assertEquals ( k , '{foo}_bar' )
270276 assertEquals ( v , JSON . stringify ( { hello : 'world' } ) )
271277 assertObjectMatch ( opts , { px : 123 } )
272278 return Promise . resolve ( 'OK' )
273279 } ,
274- get : ( k ) => k === 'store_foo' ? Promise . resolve ( '{"active": true}' ) : Promise . resolve ( null ) ,
280+ get : ( k ) =>
281+ k === 'store_foo'
282+ ? Promise . resolve ( JSON . stringify ( { active : true } ) )
283+ : Promise . resolve ( undefined ) ,
275284 } , baseOptions )
276285
277286 const result = await adapter . updateDoc ( {
0 commit comments