@@ -6,7 +6,6 @@ var deserializedType = require('./deserialized-type');
66var numberType = require ( './number-type' ) ;
77var errorHandler = require ( '../util' ) . errorHandler ;
88var richText = require ( 'rich-text' ) ;
9- var MemoryDB = require ( '../../lib/db/memory' ) ;
109types . register ( deserializedType . type ) ;
1110types . register ( deserializedType . type2 ) ;
1211types . register ( numberType . type ) ;
@@ -222,8 +221,8 @@ module.exports = function() {
222221
223222 describe ( 'no snapshot metadata available' , function ( ) {
224223 beforeEach ( function ( ) {
225- var getSnapshot = MemoryDB . prototype . getSnapshot ;
226- sinon . stub ( MemoryDB . prototype , 'getSnapshot' )
224+ var getSnapshot = this . backend . db . getSnapshot ;
225+ sinon . stub ( this . backend . db , 'getSnapshot' )
227226 . callsFake ( function ( ) {
228227 var args = Array . from ( arguments ) ;
229228 var callback = args . pop ( ) ;
@@ -240,6 +239,27 @@ module.exports = function() {
240239 } ) ;
241240
242241 runCreateTests ( ) ;
242+
243+ it ( 'returns errors if the database cannot get committed op version' , function ( done ) {
244+ sinon . stub ( this . backend . db , 'getCommittedOpVersion' )
245+ . callsFake ( function ( ) {
246+ var args = Array . from ( arguments ) ;
247+ var callback = args . pop ( ) ;
248+ callback ( new Error ( 'uh-oh' ) ) ;
249+ } ) ;
250+
251+ var doc1 = this . backend . connect ( ) . get ( 'dogs' , 'fido' ) ;
252+ var doc2 = this . backend . connect ( ) . get ( 'dogs' , 'fido' ) ;
253+ async . series ( [
254+ doc1 . create . bind ( doc1 , { age : 3 } ) ,
255+ function ( next ) {
256+ doc2 . create ( { name : 'Fido' } , function ( error ) {
257+ expect ( error . message ) . to . equal ( 'uh-oh' ) ;
258+ next ( ) ;
259+ } ) ;
260+ }
261+ ] , done ) ;
262+ } ) ;
243263 } ) ;
244264
245265 function runCreateTests ( ) {
0 commit comments