forked from mongodb/node-mongodb-native
/
insert_test.js
649 lines (563 loc) · 25.3 KB
/
insert_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
var mongodb = process.env['TEST_NATIVE'] != null ? require('../lib/mongodb').native() : require('../lib/mongodb').pure();
var testCase = require('../deps/nodeunit').testCase,
debug = require('util').debug
inspect = require('util').inspect,
nodeunit = require('../deps/nodeunit'),
Db = mongodb.Db,
Cursor = mongodb.Cursor,
Script = require('vm'),
Collection = mongodb.Collection,
Server = mongodb.Server,
Step = require("../deps/step/lib/step"),
ServerManager = require('./tools/server_manager').ServerManager;
var MONGODB = 'integration_tests';
var client = new Db(MONGODB, new Server("127.0.0.1", 27017, {auto_reconnect: true, poolSize: 4}), {native_parser: (process.env['TEST_NATIVE'] != null)});
// Define the tests, we want them to run as a nested test so we only clean up the
// db connection once
var tests = testCase({
setUp: function(callback) {
client.open(function(err, db_p) {
if(numberOfTestsRun == Object.keys(tests).length) {
// If first test drop the db
client.dropDatabase(function(err, done) {
callback();
});
} else {
return callback();
}
});
},
tearDown: function(callback) {
numberOfTestsRun = numberOfTestsRun - 1;
// Drop the database and close it
if(numberOfTestsRun <= 0) {
// client.dropDatabase(function(err, done) {
// Close the client
client.close();
callback();
// });
} else {
client.close();
callback();
}
},
shouldForceMongoDbServerToAssignId : function(test) {
/// Set up server with custom pk factory
var db = new Db(MONGODB, new Server('localhost', 27017, {auto_reconnect: true}), {native_parser: (process.env['TEST_NATIVE'] != null), 'forceServerObjectId':true});
db.bson_deserializer = client.bson_deserializer;
db.bson_serializer = client.bson_serializer;
db.open(function(err, client) {
client.createCollection('test_insert2', function(err, r) {
client.collection('test_insert2', function(err, collection) {
Step(
function inserts() {
var group = this.group();
for(var i = 1; i < 1000; i++) {
collection.insert({c:i}, {safe:true}, group());
}
},
function done(err, result) {
collection.insert({a:2}, {safe:true}, function(err, r) {
collection.insert({a:3}, {safe:true}, function(err, r) {
collection.count(function(err, count) {
test.equal(1001, count);
// Locate all the entries using find
collection.find(function(err, cursor) {
cursor.toArray(function(err, results) {
test.equal(1001, results.length);
test.ok(results[0] != null);
client.close();
// Let's close the db
test.done();
});
});
});
});
});
}
)
});
});
});
},
shouldCorrectlyPerformSingleInsert : function(test) {
client.createCollection('shouldCorrectlyPerformSingleInsert', function(err, collection) {
collection.insert({a:1}, {safe:true}, function(err, result) {
collection.findOne(function(err, item) {
test.equal(1, item.a);
test.done();
})
})
})
},
shouldCorrectlyPerformBasicInsert : function(test) {
client.createCollection('test_insert', function(err, r) {
client.collection('test_insert', function(err, collection) {
Step(
function inserts() {
var group = this.group();
for(var i = 1; i < 1000; i++) {
collection.insert({c:i}, {safe:true}, group());
}
},
function done(err, result) {
collection.insert({a:2}, {safe:true}, function(err, r) {
collection.insert({a:3}, {safe:true}, function(err, r) {
collection.count(function(err, count) {
test.equal(1001, count);
// Locate all the entries using find
collection.find(function(err, cursor) {
cursor.toArray(function(err, results) {
test.equal(1001, results.length);
test.ok(results[0] != null);
// Let's close the db
test.done();
});
});
});
});
});
}
)
});
});
},
// Test multiple document insert
shouldCorrectlyHandleMultipleDocumentInsert : function(test) {
client.createCollection('test_multiple_insert', function(err, r) {
var collection = client.collection('test_multiple_insert', function(err, collection) {
var docs = [{a:1}, {a:2}];
// debug("============================================================== 0")
collection.insert(docs, {safe:true}, function(err, ids) {
// debug("============================================================== 1")
ids.forEach(function(doc) {
test.ok(((doc['_id']) instanceof client.bson_serializer.ObjectID || Object.prototype.toString.call(doc['_id']) === '[object ObjectID]'));
});
// Let's ensure we have both documents
collection.find(function(err, cursor) {
cursor.toArray(function(err, docs) {
test.equal(2, docs.length);
var results = [];
// Check that we have all the results we want
docs.forEach(function(doc) {
if(doc.a == 1 || doc.a == 2) results.push(1);
});
test.equal(2, results.length);
// Let's close the db
test.done();
});
});
});
});
});
},
shouldCorrectlyExecuteSaveInsertUpdate: function(test) {
client.createCollection('shouldCorrectlyExecuteSaveInsertUpdate', function(err, collection) {
collection.save({ email : 'save' }, {safe:true}, function() {
collection.insert({ email : 'insert' }, {safe:true}, function() {
collection.update(
{ email : 'update' },
{ email : 'update' },
{ upsert: true, safe:true},
function() {
collection.find(function(e, c) {
c.toArray(function(e, a) {
test.equal(3, a.length)
test.done();
});
});
}
);
});
});
});
},
shouldCorrectlyInsertAndRetrieveLargeIntegratedArrayDocument : function(test) {
client.createCollection('test_should_deserialize_large_integrated_array', function(err, collection) {
var doc = {'a':0,
'b':['tmp1', 'tmp2', 'tmp3', 'tmp4', 'tmp5', 'tmp6', 'tmp7', 'tmp8', 'tmp9', 'tmp10', 'tmp11', 'tmp12', 'tmp13', 'tmp14', 'tmp15', 'tmp16']
};
// Insert the collection
collection.insert(doc, {safe:true}, function(err, r) {
// Fetch and check the collection
collection.findOne({'a': 0}, function(err, result) {
test.deepEqual(doc.a, result.a);
test.deepEqual(doc.b, result.b);
test.done();
});
});
});
},
shouldCorrectlyInsertAndRetrieveDocumentWithAllTypes : function(test) {
client.createCollection('test_all_serialization_types', function(err, collection) {
var date = new Date();
var oid = new client.bson_serializer.ObjectID();
var string = 'binstring'
var bin = new client.bson_serializer.Binary()
for(var index = 0; index < string.length; index++) {
bin.put(string.charAt(index))
}
var motherOfAllDocuments = {
'string': 'hello',
'array': [1,2,3],
'hash': {'a':1, 'b':2},
'date': date,
'oid': oid,
'binary': bin,
'int': 42,
'float': 33.3333,
'regexp': /regexp/,
'boolean': true,
'long': date.getTime(),
'where': new client.bson_serializer.Code('this.a > i', {i:1}),
'dbref': new client.bson_serializer.DBRef('namespace', oid, 'integration_tests_')
}
collection.insert(motherOfAllDocuments, {safe:true}, function(err, docs) {
collection.findOne(function(err, doc) {
// Assert correct deserialization of the values
test.equal(motherOfAllDocuments.string, doc.string);
test.deepEqual(motherOfAllDocuments.array, doc.array);
test.equal(motherOfAllDocuments.hash.a, doc.hash.a);
test.equal(motherOfAllDocuments.hash.b, doc.hash.b);
test.equal(date.getTime(), doc.long);
test.equal(date.toString(), doc.date.toString());
test.equal(date.getTime(), doc.date.getTime());
test.equal(motherOfAllDocuments.oid.toHexString(), doc.oid.toHexString());
test.equal(motherOfAllDocuments.binary.value(), doc.binary.value());
test.equal(motherOfAllDocuments.int, doc.int);
test.equal(motherOfAllDocuments.long, doc.long);
test.equal(motherOfAllDocuments.float, doc.float);
test.equal(motherOfAllDocuments.regexp.toString(), doc.regexp.toString());
test.equal(motherOfAllDocuments.boolean, doc.boolean);
test.equal(motherOfAllDocuments.where.code, doc.where.code);
test.equal(motherOfAllDocuments.where.scope['i'], doc.where.scope.i);
test.equal(motherOfAllDocuments.dbref.namespace, doc.dbref.namespace);
test.equal(motherOfAllDocuments.dbref.oid.toHexString(), doc.dbref.oid.toHexString());
test.equal(motherOfAllDocuments.dbref.db, doc.dbref.db);
test.done();
})
});
});
},
shouldCorrectlyInsertAndUpdateDocumentWithNewScriptContext: function(test) {
var db = new Db(MONGODB, new Server('localhost', 27017, {auto_reconnect: true}), {native_parser: (process.env['TEST_NATIVE'] != null)});
db.bson_deserializer = client.bson_deserializer;
db.bson_serializer = client.bson_serializer;
db.pkFactory = client.pkFactory;
db.open(function(err, db) {
//convience curried handler for functions of type 'a -> (err, result)
function getResult(callback){
return function(error, result) {
test.ok(error == null);
return callback(result);
}
};
db.collection('users', getResult(function(user_collection){
user_collection.remove({}, {safe:true}, function(err, result) {
//first, create a user object
var newUser = { name : 'Test Account', settings : {} };
user_collection.insert([newUser], {safe:true}, getResult(function(users){
var user = users[0];
var scriptCode = "settings.block = []; settings.block.push('test');";
var context = { settings : { thisOneWorks : "somestring" } };
Script.runInNewContext(scriptCode, context, "testScript");
//now create update command and issue it
var updateCommand = { $set : context };
user_collection.update({_id : user._id}, updateCommand, {safe:true},
getResult(function(updateCommand) {
// Fetch the object and check that the changes are persisted
user_collection.findOne({_id : user._id}, function(err, doc) {
test.ok(err == null);
test.equal("Test Account", doc.name);
test.equal("somestring", doc.settings.thisOneWorks);
test.equal("test", doc.settings.block[0]);
// Let's close the db
db.close();
test.done();
});
})
);
}));
});
}));
});
},
shouldCorrectlySerializeDocumentWithAllTypesInNewContext : function(test) {
client.createCollection('test_all_serialization_types_new_context', function(err, collection) {
var date = new Date();
var scriptCode =
"var string = 'binstring'\n" +
"var bin = new mongo.Binary()\n" +
"for(var index = 0; index < string.length; index++) {\n" +
" bin.put(string.charAt(index))\n" +
"}\n" +
"motherOfAllDocuments['string'] = 'hello';" +
"motherOfAllDocuments['array'] = [1,2,3];" +
"motherOfAllDocuments['hash'] = {'a':1, 'b':2};" +
"motherOfAllDocuments['date'] = date;" +
"motherOfAllDocuments['oid'] = new mongo.ObjectID();" +
"motherOfAllDocuments['binary'] = bin;" +
"motherOfAllDocuments['int'] = 42;" +
"motherOfAllDocuments['float'] = 33.3333;" +
"motherOfAllDocuments['regexp'] = /regexp/;" +
"motherOfAllDocuments['boolean'] = true;" +
"motherOfAllDocuments['long'] = motherOfAllDocuments['date'].getTime();" +
"motherOfAllDocuments['where'] = new mongo.Code('this.a > i', {i:1});" +
"motherOfAllDocuments['dbref'] = new mongo.DBRef('namespace', motherOfAllDocuments['oid'], 'integration_tests_');";
var context = { motherOfAllDocuments : {}, mongo:client.bson_serializer, date:date};
// Execute function in context
Script.runInNewContext(scriptCode, context, "testScript");
// sys.puts(sys.inspect(context.motherOfAllDocuments))
var motherOfAllDocuments = context.motherOfAllDocuments;
collection.insert(context.motherOfAllDocuments, {safe:true}, function(err, docs) {
collection.findOne(function(err, doc) {
// Assert correct deserialization of the values
test.equal(motherOfAllDocuments.string, doc.string);
test.deepEqual(motherOfAllDocuments.array, doc.array);
test.equal(motherOfAllDocuments.hash.a, doc.hash.a);
test.equal(motherOfAllDocuments.hash.b, doc.hash.b);
test.equal(date.getTime(), doc.long);
test.equal(date.toString(), doc.date.toString());
test.equal(date.getTime(), doc.date.getTime());
test.equal(motherOfAllDocuments.oid.toHexString(), doc.oid.toHexString());
test.equal(motherOfAllDocuments.binary.value(), doc.binary.value());
test.equal(motherOfAllDocuments.int, doc.int);
test.equal(motherOfAllDocuments.long, doc.long);
test.equal(motherOfAllDocuments.float, doc.float);
test.equal(motherOfAllDocuments.regexp.toString(), doc.regexp.toString());
test.equal(motherOfAllDocuments.boolean, doc.boolean);
test.equal(motherOfAllDocuments.where.code, doc.where.code);
test.equal(motherOfAllDocuments.where.scope['i'], doc.where.scope.i);
test.equal(motherOfAllDocuments.dbref.namespace, doc.dbref.namespace);
test.equal(motherOfAllDocuments.dbref.oid.toHexString(), doc.dbref.oid.toHexString());
test.equal(motherOfAllDocuments.dbref.db, doc.dbref.db);
test.done();
})
});
});
},
shouldCorrectlyDoToJsonForLongValue : function(test) {
client.createCollection('test_to_json_for_long', function(err, collection) {
test.ok(collection instanceof Collection);
collection.insertAll([{value: client.bson_serializer.Long.fromNumber(32222432)}], {safe:true}, function(err, ids) {
collection.findOne({}, function(err, item) {
test.equal("32222432", item.value.toJSON())
test.done();
});
});
});
},
shouldCorrectlyInsertAndUpdateWithNoCallback : function(test) {
var db = new Db(MONGODB, new Server('localhost', 27017, {auto_reconnect: true, poolSize: 1}), {native_parser: (process.env['TEST_NATIVE'] != null)});
db.bson_deserializer = client.bson_deserializer;
db.bson_serializer = client.bson_serializer;
db.pkFactory = client.pkFactory;
db.open(function(err, client) {
client.createCollection('test_insert_and_update_no_callback', function(err, collection) {
// Insert the update
collection.insert({i:1}, {safe:true})
// Update the record
collection.update({i:1}, {"$set":{i:2}}, {safe:true})
// Make sure we leave enough time for mongodb to record the data
setTimeout(function() {
// Locate document
collection.findOne({}, function(err, item) {
test.equal(2, item.i)
client.close();
test.done();
});
}, 100)
})
});
},
shouldInsertAndQueryTimestamp : function(test) {
client.createCollection('test_insert_and_query_timestamp', function(err, collection) {
// Insert the update
collection.insert({i:client.bson_serializer.Timestamp.fromNumber(100), j:client.bson_serializer.Long.fromNumber(200)}, {safe:true}, function(err, r) {
// Locate document
collection.findOne({}, function(err, item) {
test.equal(100, item.i.toNumber())
test.equal(200, item.j.toNumber())
test.done();
});
})
})
},
shouldCorrectlyInsertAndQueryUndefined : function(test) {
client.createCollection('test_insert_and_query_undefined', function(err, collection) {
// Insert the update
collection.insert({i:undefined}, {safe:true}, function(err, r) {
// Locate document
collection.findOne({}, function(err, item) {
test.equal(null, item.i)
test.done();
});
})
})
},
shouldCorrectlySerializeDBRefToJSON : function(test) {
var dbref = new client.bson_serializer.DBRef("foo",
client.bson_serializer.ObjectID.createFromHexString("fc24a04d4560531f00000000"),
null);
JSON.stringify(dbref);
test.done();
},
shouldCorrectlyPerformSafeInsert : function(test) {
var fixtures = [{
name: "empty", array: [], bool: false, dict: {}, float: 0.0, string: ""
}, {
name: "not empty", array: [1], bool: true, dict: {x: "y"}, float: 1.0, string: "something"
}, {
name: "simple nested", array: [1, [2, [3]]], bool: true, dict: {x: "y", array: [1,2,3,4], dict: {x: "y", array: [1,2,3,4]}}, float: 1.5, string: "something simply nested"
}];
client.createCollection('test_safe_insert', function(err, collection) {
Step(
function inserts() {
var group = this.group();
for(var i = 0; i < fixtures.length; i++) {
collection.insert(fixtures[i], {safe:true}, group());
}
},
function done() {
collection.count(function(err, count) {
test.equal(3, count);
collection.find().toArray(function(err, docs) {
test.equal(3, docs.length)
});
});
collection.find({}, {}, function(err, cursor) {
var counter = 0;
cursor.each(function(err, doc) {
if(doc == null) {
test.equal(3, counter);
test.done();
} else {
counter = counter + 1;
}
});
});
}
)
})
},
shouldThrowErrorIfSerializingFunction : function(test) {
client.createCollection('test_should_throw_error_if_serializing_function', function(err, collection) {
// Insert the update
collection.insert({i:1, z:function() { return 1} }, {safe:true}, function(err, result) {
collection.findOne({_id:result[0]._id}, function(err, object) {
test.equal(null, object.z);
test.equal(1, object.i);
test.done();
})
})
})
},
shouldCorrectlyInsertDocumentWithUUID : function(test) {
client.collection("insert_doc_with_uuid", function(err, collection) {
collection.insert({_id : "12345678123456781234567812345678", field: '1'}, {safe:true}, function(err, result) {
test.equal(null, err);
collection.find({_id : "12345678123456781234567812345678"}).toArray(function(err, items) {
test.equal(null, err);
test.equal(items[0]._id, "12345678123456781234567812345678")
test.equal(items[0].field, '1')
// Generate a binary id
var binaryUUID = new client.bson_serializer.Binary('00000078123456781234567812345678', client.bson_serializer.BSON.BSON_BINARY_SUBTYPE_UUID);
collection.insert({_id : binaryUUID, field: '2'}, {safe:true}, function(err, result) {
collection.find({_id : binaryUUID}).toArray(function(err, items) {
test.equal(null, err);
test.equal(items[0].field, '2')
test.done();
});
});
})
});
});
},
shouldCorrectlyCallCallbackWithDbDriverInStrictMode : function(test) {
var db = new Db(MONGODB, new Server('localhost', 27017, {auto_reconnect: true, poolSize: 1}), {strict:true, native_parser: (process.env['TEST_NATIVE'] != null)});
db.bson_deserializer = client.bson_deserializer;
db.bson_serializer = client.bson_serializer;
db.pkFactory = client.pkFactory;
db.open(function(err, client) {
client.createCollection('test_insert_and_update_no_callback_strict', function(err, collection) {
collection.insert({_id : "12345678123456781234567812345678", field: '1'}, {safe:true}, function(err, result) {
test.equal(null, err);
collection.update({ '_id': "12345678123456781234567812345678" }, { '$set': { 'field': 0 }}, function(err, numberOfUpdates) {
test.equal(null, err);
test.equal(1, numberOfUpdates);
db.close();
test.done();
});
});
});
});
},
shouldCorrectlyInsertDBRefWithDbNotDefined : function(test) {
client.createCollection('shouldCorrectlyInsertDBRefWithDbNotDefined', function(err, collection) {
var doc = {_id: new client.bson_serializer.ObjectID()};
var doc2 = {_id: new client.bson_serializer.ObjectID()};
var doc3 = {_id: new client.bson_serializer.ObjectID()};
collection.insert(doc, {safe:true}, function(err, result) {
// Create object with dbref
doc2.ref = new client.bson_serializer.DBRef('shouldCorrectlyInsertDBRefWithDbNotDefined', doc._id);
doc3.ref = new client.bson_serializer.DBRef('shouldCorrectlyInsertDBRefWithDbNotDefined', doc._id, MONGODB);
collection.insert([doc2, doc3], {safe:true}, function(err, result) {
// Get all items
collection.find().toArray(function(err, items) {
test.equal("shouldCorrectlyInsertDBRefWithDbNotDefined", items[1].ref.namespace);
test.equal(doc._id.toString(), items[1].ref.oid.toString());
test.equal(null, items[1].ref.db);
test.equal("shouldCorrectlyInsertDBRefWithDbNotDefined", items[2].ref.namespace);
test.equal(doc._id.toString(), items[2].ref.oid.toString());
test.equal(MONGODB, items[2].ref.db);
test.done();
})
});
});
});
},
shouldCorrectlyInsertUpdateRemoveWithNoOptions : function(test) {
var db = new Db(MONGODB, new Server('localhost', 27017, {auto_reconnect: true}), {native_parser: (process.env['TEST_NATIVE'] != null)});
db.bson_deserializer = client.bson_deserializer;
db.bson_serializer = client.bson_serializer;
db.pkFactory = client.pkFactory;
db.open(function(err, db) {
db.collection('shouldCorrectlyInsertUpdateRemoveWithNoOptions', function(err, collection) {
collection.insert({a:1});//, function(err, result) {
collection.update({a:1}, {a:2});//, function(err, result) {
collection.remove({a:2});//, function(err, result) {
collection.count(function(err, count) {
test.equal(0, count);
db.close();
test.done();
})
});
});
},
shouldCorrectlyExecuteMultipleFetches : function(test) {
var db = new Db(MONGODB, new Server('localhost', 27017, {auto_reconnect: true}), {native_parser: (process.env['TEST_NATIVE'] != null)});
db.bson_deserializer = client.bson_deserializer;
db.bson_serializer = client.bson_serializer;
db.pkFactory = client.pkFactory;
// Search parameter
var to = 'ralph'
// Execute query
db.open(function(err, db) {
db.collection('shouldCorrectlyExecuteMultipleFetches', function(err, collection) {
collection.insert({addresses:{localPart:'ralph'}}, {safe:true}, function(err, result) {
// Let's find our user
collection.findOne({"addresses.localPart" : to}, function( err, doc ) {
test.equal(null, err);
test.equal(to, doc.addresses.localPart);
db.close();
test.done();
});
});
});
});
}
})
// Stupid freaking workaround due to there being no way to run setup once for each suite
var numberOfTestsRun = Object.keys(tests).length;
// Assign out tests
module.exports = tests;