         @db.writeSnapshot @cName, @docName, data, (err) =>
           throw Error(err) if err
           @db.bulkGetSnapshot {testcollection:['does not exist', @docName, 'also does not exist']}, (err, results) =>
+            throw Error(err) if err
             expected = {testcollection:{}}
             expected.testcollection[@docName] = data
+            delete results[@cName][@docName].docName
             assert.deepEqual results, expected
             done()
 


counter = 1

module.exports = (create) ->
  # Test if the database has getBulkSnapshots so we know to run the tests (below).
  db = create()
  db.close()

  describe 'snapshot db', ->
    beforeEach (done) ->
      @cName = 'testcollection'
      @docName = "snapshottest #{counter++}"
      if create.length is 0
        @db = create()
        done()
      else
        create (@db) =>
          done()

    afterEach ->
      @db.close()

        @db.writeSnapshot @cName, @docName, data, (err) =>
          throw Error(err) if err
          @db.bulkGetSnapshot {testcollection:[@docName]}, (err, results) =>
            throw Error(err) if err
            expected = {testcollection:{}}
            expected.testcollection[@docName] = data
            delete results[@cName][@docName].docName
            assert.deepEqual results, expected
            done()

