New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bulk-mongodb

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bulk-mongodb

bulk insert data into mongdb for integration tests

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-80%
Maintainers
1
Weekly downloads
 
Created
Source

bulk-mongodb

bulk-mongodb is a utility to assist integration testing, it simply bulk inserts documents into collections, and allows you to drop them.

build status

Install

$ npm install bulk-mongodb --save-dev

Setup

Consider the following test, the before block, setups a data set with an array of things to import. We create a BulkMongoDb, passing in a mongodb url, and the data set. we then execute bulkMongoDb.insert, which runs the bulk insert. The after block cleans this up by dropping the collections we added.

'use strict';

var assert        = require('assert');
var BulkMongoDb   = require('./');

describe('notifications', function() {
  var bulkMongoDb;

  before(function(done){
    var notifications = require('./fixtures/notifications');
    var users         = require('./fixtures/users');
    
    var url = 'mongodb://localhost:27017/bulkMongoDbtest'

    var data = [
      { collection : 'notifications', documents : notifications },
      { collection : 'users', documents : users }  
    ];
 
    bulkMongoDb = new BulkMongoDb(url, data);

    bulkMongoDb.insert(function() {
      done();
    });
  });

  after(function(done) {
    bulkMongoDb.drop(function(){
      done();
    });
  });

  describe('when doing something which needs mongodb', function() {
    it('should return a valid response', function(){
      assert(true);
    });
  });
});

Fixtures

The fixture used in the above example.

[
  { "title" : "notification one", "status" : "active"   },
  { "title" : "notification two", "status" : "active"   },
  { "title" : "notification three", "status" : "active" },
  { "title" : "notification four", "status" : "active"  },
  { "title" : "notification five", "status" : "deleted" }
]

Test

$ npm test

License

This work is licensed under the MIT License (see the LICENSE file).

https://github.com/AndrewKeig/bulk-mongodb/blob/master/LICENSE

Keywords

FAQs

Package last updated on 29 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc