This repository was archived by the owner on Sep 4, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11language : node_js
22node_js :
3+ - " 0.12"
34 - " 0.11"
45 - " 0.10"
Original file line number Diff line number Diff line change @@ -66,4 +66,6 @@ Add unit tests for any new or changed functionality. Lint and test your code.
6666
6767## Release History
6868
69+ * 1.1.1 Fixed the tests to mock mongoose
70+ * 1.1.0 Added option for changing the collection
6971* 1.0.0 Initial release
Original file line number Diff line number Diff line change 11{
22 "name" : " is-master" ,
3- "version" : " 1.1.0 " ,
3+ "version" : " 1.1.1 " ,
44 "description" : " Find the master node process in a multi server cluster." ,
55 "main" : " is-master.js" ,
66 "scripts" : {
3232 "homepage" : " https://github.com/mattpker/node-is-master" ,
3333 "devDependencies" : {
3434 "chai" : " ^1.10.0" ,
35+ "install" : " ^0.1.8" ,
3536 "mocha" : " ^2.1.0" ,
36- "mongoose" : " ^3.8.22"
37+ "mongoose" : " ^4.0.6" ,
38+ "mongoose-mock" : " ^0.4.0" ,
39+ "npm" : " ^2.12.1" ,
40+ "proxyquire" : " ^1.6.0" ,
41+ "sinon" : " ^1.15.4" ,
42+ "sinon-chai" : " ^2.8.0"
3743 }
3844}
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- var expect = require ( "../node_modules/chai" ) . expect ;
3+ var chai = require ( "../node_modules/chai" ) ;
4+ var expect = chai . expect ;
45var mongoose = require ( '../node_modules/mongoose' ) ;
5- var im = require ( '../is-master.js' ) ;
6+ var mongooseMock = require ( 'mongoose-mock' ) ;
7+ var proxyquire = require ( 'proxyquire' ) ;
8+ var sinon = require ( 'sinon' ) ;
9+ var sinonChai = require ( "sinon-chai" ) ;
610
7- // Bootstrap db connection
8- mongoose . connect ( 'mongodb://127.0.0.1:27017/im' , function ( err ) {
9- if ( err ) {
10- console . error ( '\x1b[31m' , 'Could not connect to MongoDB!' ) ;
11- throw ( err ) ;
12- }
13- } ) ;
11+ chai . use ( sinonChai ) ;
1412
1513describe ( "is-master" , function ( ) {
14+
15+ var im ;
16+
17+ beforeEach ( function ( ) {
18+ im = proxyquire ( '../is-master.js' , {
19+ 'mongoose' : mongooseMock
20+ } ) ;
21+ } ) ;
22+
1623 it ( "should start the worker" , function ( done ) {
1724 im . start ( {
1825 collection : 'testcol' ,
You can’t perform that action at this time.
0 commit comments