@@ -41,7 +41,7 @@ type RunOperationFn = (
41
41
) => Promise < Document | boolean | number | null | void | string > ;
42
42
export const operations = new Map < string , RunOperationFn > ( ) ;
43
43
44
- export class MalformedOperationError extends AssertionError { }
44
+ export class MalformedOperationError extends AssertionError { }
45
45
46
46
operations . set ( 'createEntities' , async ( { entities, operation, testConfig } ) => {
47
47
if ( ! operation . arguments ?. entities ) {
@@ -208,19 +208,19 @@ operations.set('close', async ({ entities, operation }) => {
208
208
const timeoutMS = operation . arguments ?. timeoutMS ;
209
209
await cursor . close ( { timeoutMS } ) ;
210
210
return ;
211
- } catch { }
211
+ } catch { }
212
212
213
213
try {
214
214
const changeStream = entities . getEntity ( 'stream' , operation . object ) ;
215
215
await changeStream . close ( ) ;
216
216
return ;
217
- } catch { }
217
+ } catch { }
218
218
219
219
try {
220
220
const client = entities . getEntity ( 'client' , operation . object ) ;
221
221
await client . close ( ) ;
222
222
return ;
223
- } catch { }
223
+ } catch { }
224
224
/* eslint-enable no-empty */
225
225
226
226
throw new AssertionError ( `No closable entity with key ${ operation . object } ` ) ;
@@ -257,8 +257,8 @@ operations.set('createCollection', async ({ entities, operation }) => {
257
257
258
258
operations . set ( 'createFindCursor' , async ( { entities, operation } ) => {
259
259
const collection = entities . getEntity ( 'collection' , operation . object ) ;
260
- const { filter, ...opts } = operation . arguments ! ;
261
- switch ( opts . cursorType ) {
260
+ const { filter, cursorType , ...opts } = operation . arguments ! ;
261
+ switch ( cursorType ) {
262
262
case 'tailableAwait' :
263
263
opts . tailable = true ;
264
264
opts . awaitData = true ;
@@ -269,7 +269,6 @@ operations.set('createFindCursor', async ({ entities, operation }) => {
269
269
default :
270
270
break ;
271
271
}
272
- delete opts . cursorType ;
273
272
const cursor = collection . find ( filter , opts ) ;
274
273
// The spec dictates that we create the cursor and force the find command
275
274
// to execute, but don't move the cursor forward. hasNext() accomplishes
@@ -333,8 +332,8 @@ operations.set('find', async ({ entities, operation }) => {
333
332
} else {
334
333
queryable = entities . getEntity ( 'collection' , operation . object ) ;
335
334
}
336
- const { filter, ...opts } = operation . arguments ! ;
337
- switch ( opts . cursorType ) {
335
+ const { filter, cursorType , ...opts } = operation . arguments ! ;
336
+ switch ( cursorType ) {
338
337
case 'tailableAwait' :
339
338
opts . tailable = true ;
340
339
opts . awaitData = true ;
@@ -345,7 +344,6 @@ operations.set('find', async ({ entities, operation }) => {
345
344
default :
346
345
break ;
347
346
}
348
- delete opts . cursorType ;
349
347
return queryable . find ( filter , opts ) . toArray ( ) ;
350
348
} ) ;
351
349
@@ -816,8 +814,8 @@ operations.set('runCursorCommand', async ({ entities, operation }: OperationFunc
816
814
817
815
operations . set ( 'createCommandCursor' , async ( { entities, operation } : OperationFunctionParams ) => {
818
816
const collection = entities . getEntity ( 'db' , operation . object ) ;
819
- const { command, ...opts } = operation . arguments ! ;
820
- switch ( opts . cursorType ) {
817
+ const { command, cursorType , ...opts } = operation . arguments ! ;
818
+ switch ( cursorType ) {
821
819
case 'tailableAwait' :
822
820
opts . tailable = true ;
823
821
opts . awaitData = true ;
@@ -828,7 +826,6 @@ operations.set('createCommandCursor', async ({ entities, operation }: OperationF
828
826
default :
829
827
break ;
830
828
}
831
- delete opts . cursorType ;
832
829
const cursor = collection . runCursorCommand ( command , {
833
830
readPreference : ReadPreference . fromOptions ( { readPreference : opts . readPreference } ) ,
834
831
session : opts . session ,
0 commit comments