1 | 'use strict';
|
2 |
|
3 | var mongoose = require('mongoose');
|
4 | var Mockgoose = require('../built/mockgoose').Mockgoose;
|
5 | var expect = require('chai').expect;
|
6 | var mockgoose = new Mockgoose(mongoose);
|
7 | var CatSchema = new mongoose.Schema({name: String});
|
8 | var Cat1;
|
9 | var Cat2;
|
10 |
|
11 |
|
12 | describe('bug 15', function() {
|
13 |
|
14 | before("DB1 connection", function () {
|
15 | return mockgoose.prepareStorage().then(function() {
|
16 | return mongoose.createConnection("mongodb://barbaz", { useNewUrlParser: true });
|
17 | }).then(function(db1) {
|
18 | Cat1 = db1.model('Cat', CatSchema);
|
19 | });
|
20 | });
|
21 |
|
22 |
|
23 | before("DB2 connection", function () {
|
24 | return mockgoose.prepareStorage().then(function() {
|
25 | return mongoose.createConnection("mongodb://foobar", { useNewUrlParser: true });
|
26 | }).then(function (db2) {
|
27 | Cat2 = db2.model('Cat', CatSchema);
|
28 | });
|
29 | });
|
30 |
|
31 | it("should create a cat foo", function(done) {
|
32 | Cat1.create({
|
33 | name: "foo"
|
34 | }, function(err) {
|
35 | expect(err).not.to.be.ok;
|
36 | done(err);
|
37 | });
|
38 | });
|
39 |
|
40 | it("should find cat foo", function(done) {
|
41 | Cat1.findOne({name: "foo"}, function(err) {
|
42 | expect(err).not.to.be.ok;
|
43 | done(err);
|
44 | });
|
45 | });
|
46 |
|
47 |
|
48 | after("Drop db", function(done) {
|
49 |
|
50 | mockgoose.helper.reset().then(function() {
|
51 | done();
|
52 | });
|
53 | });
|
54 | });
|