From 248e00a947a62bc47121099e6497fbddba5689e6 Mon Sep 17 00:00:00 2001 From: Paul Cortes Date: Wed, 13 Jan 2021 16:19:02 -0500 Subject: [PATCH] Ajustes de los test del modelo usuario --- newrelic_agent.log | 12 ++++++++ ...rio_test.spec2.js => usuario_test.spec.js} | 29 ++++++++++++++----- 2 files changed, 33 insertions(+), 8 deletions(-) rename spec/models/{usuario_test.spec2.js => usuario_test.spec.js} (78%) diff --git a/newrelic_agent.log b/newrelic_agent.log index 9d5a55d..eef2433 100644 --- a/newrelic_agent.log +++ b/newrelic_agent.log @@ -656,3 +656,15 @@ {"v":0,"level":30,"name":"newrelic","hostname":"PAUL-LENOVO","pid":16358,"time":"2021-01-13T21:17:01.077Z","msg":"Valid event_harvest_config received. Updating harvest cycles. {\"report_period_ms\":5000,\"harvest_limits\":{\"error_event_data\":8,\"analytic_event_data\":833,\"custom_event_data\":83}}"} {"v":0,"level":30,"name":"newrelic","hostname":"PAUL-LENOVO","pid":16358,"time":"2021-01-13T21:17:01.079Z","msg":"Agent state changed from connected to started."} {"v":0,"level":30,"name":"newrelic","hostname":"PAUL-LENOVO","pid":16358,"time":"2021-01-13T21:17:02.079Z","msg":"Starting initial 1000ms harvest."} +{"v":0,"level":30,"name":"newrelic","hostname":"PAUL-LENOVO","pid":16836,"time":"2021-01-13T21:18:34.517Z","msg":"Using New Relic for Node.js. Agent version: 6.12.0; Node version: v14.15.4."} +{"v":0,"level":40,"name":"newrelic","hostname":"PAUL-LENOVO","pid":16836,"time":"2021-01-13T21:18:34.609Z","msg":"The newrelic module must be the first module required.\nThe following modules were required before newrelic and are not being instrumented:\n\tmongodb: /home/paul/projects/node/red_bicicletas/node_modules/mongodb/index.js\n\tbluebird: /home/paul/projects/node/red_bicicletas/node_modules/bluebird/js/release/bluebird.js"} +{"v":0,"level":30,"name":"newrelic","hostname":"PAUL-LENOVO","pid":16836,"time":"2021-01-13T21:18:34.609Z","msg":"Agent state changed from stopped to starting."} +{"v":0,"level":30,"name":"newrelic","hostname":"PAUL-LENOVO","pid":16836,"time":"2021-01-13T21:18:34.691Z","msg":"Starting New Relic for Node.js connection process."} +{"v":0,"level":30,"name":"newrelic","hostname":"PAUL-LENOVO","pid":16836,"time":"2021-01-13T21:18:34.691Z","msg":"Agent state changed from starting to connecting."} +{"v":0,"level":40,"name":"newrelic","hostname":"PAUL-LENOVO","pid":16836,"time":"2021-01-13T21:18:36.396Z","msg":"Unable to retrieve cached path for one or more modules with an already loaded parent. Forcing resolution. This should not occur during normal agent execution. Module resolution performance my be impacted. See trace-level logs for specific modules.","component":"shimmer"} +{"v":0,"level":30,"name":"newrelic","hostname":"PAUL-LENOVO","pid":16836,"time":"2021-01-13T21:18:36.980Z","msg":"Agent state changed from connecting to connected."} +{"v":0,"level":30,"name":"newrelic","hostname":"PAUL-LENOVO","pid":16836,"time":"2021-01-13T21:18:36.981Z","msg":"Connected to collector-003.newrelic.com:443 with agent run ID BckGZnWABxWwACtCOTDJZxtf_2QAAAgBAAAnIQEAAEHEAgQl7KHvAwAGNi4xMi4wAAtQQVVMLUxFTk9WTwAOUmVkLUJpY2ljbGV0YXM.","component":"collector_api"} +{"v":0,"level":30,"name":"newrelic","hostname":"PAUL-LENOVO","pid":16836,"time":"2021-01-13T21:18:36.981Z","msg":"Reporting to: https://rpm.newrelic.com/accounts/2835001/applications/636264943","component":"collector_api"} +{"v":0,"level":30,"name":"newrelic","hostname":"PAUL-LENOVO","pid":16836,"time":"2021-01-13T21:18:36.982Z","msg":"Valid event_harvest_config received. Updating harvest cycles. {\"report_period_ms\":5000,\"harvest_limits\":{\"error_event_data\":8,\"analytic_event_data\":833,\"custom_event_data\":83}}"} +{"v":0,"level":30,"name":"newrelic","hostname":"PAUL-LENOVO","pid":16836,"time":"2021-01-13T21:18:36.985Z","msg":"Agent state changed from connected to started."} +{"v":0,"level":30,"name":"newrelic","hostname":"PAUL-LENOVO","pid":16836,"time":"2021-01-13T21:18:37.986Z","msg":"Starting initial 1000ms harvest."} diff --git a/spec/models/usuario_test.spec2.js b/spec/models/usuario_test.spec.js similarity index 78% rename from spec/models/usuario_test.spec2.js rename to spec/models/usuario_test.spec.js index d99de1f..1f66e6a 100644 --- a/spec/models/usuario_test.spec2.js +++ b/spec/models/usuario_test.spec.js @@ -1,3 +1,4 @@ +require('dotenv').config(); var mongoose = require('mongoose') var Bicicleta = require('../../models/bicicleta') var Reserva = require('../../models/reserva'); @@ -6,20 +7,32 @@ var Usuario = require('../../models/usuario'); describe('Testing Usuarios', function () { - beforeEach(function (done) { - // var mongoDB = 'mongodb://localhost/testdb' - var mongoDB = 'mongodb+srv://strider:Qj7bTtEvyRqZW5mG@cluster0-vbnxk.mongodb.net/testdb'; + let db; + conectar = (done) => { + var mongoDB = process.env.MONGO_URI; + console.log("mongoDB: ", mongoDB) mongoose.connect(mongoDB, { useNewUrlParser: true, - useUnifiedTopology: true + useUnifiedTopology: true, + useCreateIndex: true, + useFindAndModify: false }) - const db = mongoose.connection - db.on('error', console.error.bind(console, 'connection error')) + db = mongoose.connection; + db.on('error', console.error.bind(console, 'connection error')); db.once('open', function () { - console.log('We are connected to test database') - done() + console.log('We are connected to test database!'); + done(); }) + } + beforeAll(function (done) { + // var mongoDB = 'mongodb://localhost/testdb' + if (mongoose.connection.readyState) { + db = mongoose.connection; + done(); + } else { + conectar(done); + } }) afterEach(function (done) {