File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -270,5 +270,18 @@ mod tests {
270270 let bogus_id = TestObjectId { id : [ 84u8 ; 4 ] } ;
271271 let update = TestObjectUpdate { id : bogus_id, data : [ 12u8 ; 3 ] } ;
272272 assert_eq ! ( Ok ( DataStoreUpdateResult :: NotFound ) , data_store. update( & update) ) ;
273+
274+ // Check `insert_or_update` inserts unknown objects
275+ let iou_id = TestObjectId { id : [ 55u8 ; 4 ] } ;
276+ let iou_object = TestObject { id : iou_id, data : [ 34u8 ; 3 ] } ;
277+ assert_eq ! ( Ok ( true ) , data_store. insert_or_update( & iou_object) ) ;
278+
279+ // Check `insert_or_update` doesn't update the same object
280+ assert_eq ! ( Ok ( false ) , data_store. insert_or_update( & iou_object) ) ;
281+
282+ // Check `insert_or_update` updates if object changed
283+ let mut new_iou_object = iou_object. clone ( ) ;
284+ new_iou_object. data [ 0 ] += 1 ;
285+ assert_eq ! ( Ok ( true ) , data_store. insert_or_update( & new_iou_object) ) ;
273286 }
274287}
You can’t perform that action at this time.
0 commit comments