@@ -166,12 +166,7 @@ function prepareDatabaseForSuite(suite, context) {
166166 context . collectionName = suite . collection_name ;
167167
168168 const db = context . sharedClient . db ( context . dbName ) ;
169- if ( context . collectionName == null ) {
170- return db . admin ( ) . command ( { killAllSessions : [ ] } ) ;
171- }
172-
173- const coll = db . collection ( context . collectionName ) ;
174- return db
169+ const setupPromise = db
175170 . admin ( )
176171 . command ( { killAllSessions : [ ] } )
177172 . catch ( err => {
@@ -180,7 +175,14 @@ function prepareDatabaseForSuite(suite, context) {
180175 }
181176
182177 throw err ;
183- } )
178+ } ) ;
179+
180+ if ( context . collectionName == null ) {
181+ return setupPromise ;
182+ }
183+
184+ const coll = db . collection ( context . collectionName ) ;
185+ return setupPromise
184186 . then ( ( ) => coll . drop ( { writeConcern : 'majority' } ) )
185187 . catch ( err => {
186188 if ( ! err . message . match ( / n s n o t f o u n d / ) ) throw err ;
@@ -518,11 +520,12 @@ function testOperation(operation, obj, context, options) {
518520 }
519521
520522 if ( operation . error ) {
521- opPromise = opPromise
522- . then ( ( ) => {
523+ opPromise = opPromise . then (
524+ ( ) => {
523525 throw new Error ( 'expected an error!' ) ;
524- } )
525- . catch ( ( ) => { } ) ;
526+ } ,
527+ ( ) => { }
528+ ) ;
526529 }
527530
528531 if ( operation . result ) {
@@ -534,11 +537,11 @@ function testOperation(operation, obj, context, options) {
534537 result . errorLabelsContain ||
535538 result . errorLabelsOmit
536539 ) {
537- return opPromise
538- . then ( ( ) => {
540+ return opPromise . then (
541+ ( ) => {
539542 throw new Error ( 'expected an error!' ) ;
540- } )
541- . catch ( err => {
543+ } ,
544+ err => {
542545 const errorContains = result . errorContains ;
543546 const errorCodeName = result . errorCodeName ;
544547 const errorLabelsContain = result . errorLabelsContain ;
@@ -566,7 +569,8 @@ function testOperation(operation, obj, context, options) {
566569 if ( ! options . swallowOperationErrors ) {
567570 throw err ;
568571 }
569- } ) ;
572+ }
573+ ) ;
570574 }
571575
572576 return opPromise . then ( opResult => {
0 commit comments