@@ -1023,6 +1023,35 @@ describe('CRUD API', function() {
1023
1023
}
1024
1024
} ) ;
1025
1025
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
+
1026
1055
it ( 'should correctly throw error if update doc for updateOne lacks atomic operator' , {
1027
1056
// Add a tag that our runner can trigger on
1028
1057
// in this case we are setting that node needs to be higher than 0.10.X to run
0 commit comments