<commit_before>/* Copyright (c) 2012-2015 LevelUP contributors
 * See list at <https://github.com/level/levelup#contributing>
 * MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
 */

var levelup = require('../lib/levelup')
  , errors  = levelup.errors
  , async   = require('async')
  , common  = require('./common')

  , assert  = require('referee').assert
  , refute  = require('referee').refute
  , buster  = require('bustermove')

buster.testCase('batch()', {
    'setUp': common.commonSetUp
  , 'tearDown': common.commonTearDown

  , 'batch() with multiple puts': function (done) {
      this.openTestDatabase(function (db) {
        db.batch(
            [
                { type: 'put', key: 'foo', value: 'afoovalue' }
              , { type: 'put', key: 'bar', value: 'abarvalue' }
              , { type: 'put', key: 'baz', value: 'abazvalue' }
            ]
          , function (err) {
              refute(err)
              async.forEach(
                  ['foo', 'bar', 'baz']<commit_msg>add failing test<commit_after>/* Copyright (c) 2012-2015 LevelUP contributors
 * See list at <https://github.com/level/levelup#contributing>
 * MIT License <https://github.com/level/levelup/blob/master/LICENSE.md>
 */

var levelup = require('../lib/levelup')
  , errors  = levelup.errors
  , async   = require('async')
  , common  = require('./common')

  , assert  = require('referee').assert
  , refute  = require('referee').refute
  , buster  = require('bustermove')

buster.testCase('batch()', {
    'setUp': common.commonSetUp
  , 'tearDown': common.commonTearDown

  , 'batch() with multiple puts': function (done) {
      this.openTestDatabase(function (db) {
        db.batch(
            [
                { type: 'put', key: 'foo', value: 'afoovalue' }
              , { type: 'put', key: 'bar', value: 'abarvalue' }
              , { type: 'put', key: 'baz', value: 'abazvalue' }
            ]
          , function (err) {
              refute(err)
              async.forEach(
                  ['foo', 'bar', 'baz']
                , function (key, callback) {
                    db.get(key, function (err, value) {
                      refute(err)
                      assert.equals(value, 'a' + key + 'value')
                      callback()
                    })
                  }
                , done
              )
            }
        )
      })
    }

  , 'batch() no type set defaults to put': function (done) {
      this.openTestDatabase(function (db) {
        db.batch(
            [
                { key: 'foo', value: 'afoovalue' }
              , { key: 'bar', value: 'abarvalue' }
              , { key: 'baz', value: 'abazvalue' }
            ]
          , function (err) {
              refute(err)
              async.forEach(
                  ['foo', 'bar', 'baz']
{'fraction_non_alphanumeric': 0.15767195767195769, 'fraction_numerical': 0.005643738977072311, 'mean_word_length': 1.7587548638132295, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3665505', 'n_tokens_mistral': 896, 'n_tokens_neox': 857, 'n_words': 180}