<commit_before>'use strict';

var path = require('path');
var mkdirp = require('mkdirp');
var rimraf = require('rimraf');
var chai = require('chai');
var should = chai.should();
var spawn = require('child_process').spawn;

var lmdb = require('..');
const MAX_DB_SIZE = 256 * 1024 * 1024;

describe('Node.js LMDB Bindings', function() {
  var testDirPath = path.resolve(__dirname, './testdata');
  
  // just to make a reasonable sized chunk of data...
  function expand(str) {
    str = '(' + str + ')';
    str = str + str;
    str = str + str;
    str = str + str;
    str = str + str;
    str = str + str;
    return str;
  }

  before(function(done) {
    // cleanup previous test directory
    rimraf(testDirPath, function(err) {
      if (err) {
        return done(err);
      }
      // setup clean directory
      mkdirp(testDirPath, function(err) {
        if (err) {
          return done(err);
        }
        done();
      });
    });
  });
  it('will construct, open and close an environment', function() {
    this.timeout(10000);
    var env = new lmdb.Env();
    env.open({
      path: testDirPath,
      maxDbs: 10
    });
    env.close.should.be.a('function');
    env.beginTxn.should.be.a('function');
    env.openDbi.should.be.a('function');
    env.sync.should.be.a('function');
    env.resize.should.be.a('function');
    env.close();
  });
  describe('Basics', function() {
    this.timeout(10000);
    var env;
    before(function() {
      env = new lmdb.Env();
      env.open({
        path: testDirPath,
        maxDbs: 10,
        maxReaders: 422,
        mapSize: MAX_DB_SIZE
      });
    });
    after(function() {
      env.close();
    });<commit_msg>tests: check existence of stat and info<commit_after>'use strict';

var path = require('path');
var mkdirp = require('mkdirp');
var rimraf = require('rimraf');
var chai = require('chai');
var should = chai.should();
var spawn = require('child_process').spawn;

var lmdb = require('..');
const MAX_DB_SIZE = 256 * 1024 * 1024;

describe('Node.js LMDB Bindings', function() {
  var testDirPath = path.resolve(__dirname, './testdata');
  
  // just to make a reasonable sized chunk of data...
  function expand(str) {
    str = '(' + str + ')';
    str = str + str;
    str = str + str;
    str = str + str;
    str = str + str;
    str = str + str;
    return str;
  }

  before(function(done) {
    // cleanup previous test directory
    rimraf(testDirPath, function(err) {
      if (err) {
        return done(err);
      }
      // setup clean directory
      mkdirp(testDirPath, function(err) {
        if (err) {
          return done(err);
        }
        done();
      });
    });
  });
  it('will construct, open and close an environment', function() {
    this.timeout(10000);
    var env = new lmdb.Env();
    env.open({
      path: testDirPath,
      maxDbs: 10
    });
    env.close.should.be.a('function');
    env.beginTxn.should.be.a('function');
    env.openDbi.should.be.a('function');
    env.sync.should.be.a('function');
    env.resize.should.be.a('function');
    env.stat.should.be.a('function');
    env.info.should.be.a('function');
    env.close();
  });
  describe('Basics', function() {
    this.timeout(10000);
    var env;
    before(function() {
      env = new lmdb.Env();
      env.open({
        path: testDirPath,
        maxDbs: 10,
        maxReaders: 422,
        mapSize: MAX_DB_SIZE
      });
    });
    after(function() {
      env.close();
    });
{'fraction_non_alphanumeric': 0.16484464902186421, 'fraction_numerical': 0.01611047180667434, 'mean_word_length': 2.4121687929342492, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '5130641', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1149, 'n_words': 270}