@@ -1023,6 +1023,35 @@ describe('CRUD API', function() {
10231023 }
10241024 } ) ;
10251025
1026+ it ( 'should correctly throw error if update doc for findOneAndUpdate lacks atomic operator' , function ( done ) {
1027+ let configuration = this . configuration ;
1028+ let client = configuration . newClient ( configuration . writeConcernMax ( ) , { poolSize : 1 } ) ;
1029+ client . connect ( function ( err , client ) {
1030+ expect ( err ) . to . not . exist ;
1031+ let db = client . db ( configuration . db ) ;
1032+ let col = db . collection ( 't21_1' ) ;
1033+ col . insertOne ( { a : 1 , b : 2 , c : 3 } , function ( err , r ) {
1034+ expect ( err ) . to . not . exist ;
1035+ expect ( r . insertedCount ) . to . equal ( 1 ) ;
1036+
1037+ // empty update document
1038+ col . findOneAndUpdate ( { a : 1 } , { } , function ( err , r ) {
1039+ expect ( err ) . to . exist ;
1040+ expect ( r ) . to . not . exist ;
1041+
1042+ // update document non empty but still lacks atomic operator
1043+ col . findOneAndUpdate ( { a : 1 } , { b : 5 } , function ( err , r ) {
1044+ expect ( err ) . to . exist ;
1045+ expect ( r ) . to . not . exist ;
1046+
1047+ client . close ( ) ;
1048+ done ( ) ;
1049+ } ) ;
1050+ } ) ;
1051+ } ) ;
1052+ } ) ;
1053+ } ) ;
1054+
10261055 it ( 'should correctly throw error if update doc for updateOne lacks atomic operator' , {
10271056 // Add a tag that our runner can trigger on
10281057 // in this case we are setting that node needs to be higher than 0.10.X to run
0 commit comments