<commit_before>var async = require('async'),
    should = require('chai').should(),
    mongoose = require('mongoose'),
    autoIncrement = require('..'),
    conn;

before(function (done) {
    conn = mongoose.createConnection('mongodb://127.0.0.1/mongoose-auto-increment-test');
    conn.on('error', console.error.bind(console));
    conn.once('open', function () {
        autoIncrement.initialize(conn);
        done();
    });
});

after(function (done) {
    conn.db.executeDbCommand({ dropDatabase: 1 }, function () {
        conn.close(done);
    });
});

afterEach(function (done) {
    conn.model('User').collection.drop(function () {
        delete conn.models.User;
        return conn.model('Mongoose-Auto-Increment').collection.drop(done);
    });
});

describe('mongoose-auto-increment', function () {

    it('should increment the _id field on save', function (done) {

        // Arrange
        var userSchema = new mongoose.Schema({
            name: String,
            dept: String
        });
        userSchema.plugin(autoIncrement.plugin, 'User');
        var User = conn.model('User', userSchema),
            user = new User({ name: 'Charlie', dept: 'Support' }),
            user2 = new User({ name: 'Charlene', dept: 'Marketing' });

        // Act
        async.series({
            user1: function (cb) {
                user.save(cb);
            },<commit_msg>Updated tests so they pass again.<commit_after>var async = require('async'),
    should = require('chai').should(),
    mongoose = require('mongoose'),
    autoIncrement = require('..'),
    conn;

before(function (done) {
    conn = mongoose.createConnection('mongodb://127.0.0.1/mongoose-auto-increment-test');
    conn.on('error', console.error.bind(console));
    conn.once('open', function () {
        autoIncrement.initialize(conn);
        done();
    });
});

after(function (done) {
    conn.db.executeDbCommand({ dropDatabase: 1 }, function () {
        conn.close(done);
    });
});

afterEach(function (done) {
    conn.model('User').collection.drop(function () {
        delete conn.models.User;
        return conn.model('IdentityCounter').collection.drop(done);
    });
});

describe('mongoose-auto-increment', function () {

    it('should increment the _id field on save', function (done) {

        // Arrange
        var userSchema = new mongoose.Schema({
            name: String,
            dept: String
        });
        userSchema.plugin(autoIncrement.plugin, 'User');
        var User = conn.model('User', userSchema),
            user = new User({ name: 'Charlie', dept: 'Support' }),
            user2 = new User({ name: 'Charlene', dept: 'Marketing' });

        // Act
        async.series({
            user1: function (cb) {
                user.save(cb);
            },
{'fraction_non_alphanumeric': 0.16487839771101573, 'fraction_numerical': 0.006437768240343348, 'mean_word_length': 2.4745341614906833, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '5234263', 'n_tokens_mistral': 832, 'n_tokens_neox': 821, 'n_words': 165}