Skip to content

Commit a4dee82

Browse files
committed
provide dbName
1 parent 73b761d commit a4dee82

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

packages/datadog-plugin-mongoose/test/index.spec.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
const semver = require('semver')
44
const agent = require('../../dd-trace/test/plugins/agent')
55
const { NODE_MAJOR } = require('../../../version')
6+
const id = require('../../dd-trace/src/id')
67

78
describe('Plugin', () => {
8-
let id
99
let tracer
10-
let dbName
10+
const dbName = id().toString()
1111

1212
describe('mongoose', () => {
1313
withVersions('mongoose', ['mongoose'], (version) => {
@@ -19,10 +19,10 @@ describe('Plugin', () => {
1919
// This needs to be called synchronously right before each test to make
2020
// sure a connection is not already established and the request is added
2121
// to the queue.
22-
async function connect () {
22+
function connect () {
2323
// mongoose.connect('mongodb://username:password@host:port/database?options...');
2424
// actually the first part of the path is the dbName and not the collection
25-
await mongoose.connect(`mongodb://localhost:27017/${dbName}`, {
25+
mongoose.connect(`mongodb://localhost:27017/${dbName}`, {
2626
useNewUrlParser: true,
2727
useUnifiedTopology: true
2828
})
@@ -33,11 +33,8 @@ describe('Plugin', () => {
3333
})
3434

3535
before(() => {
36-
id = require('../../dd-trace/src/id')
3736
tracer = require('../../dd-trace')
3837

39-
dbName = id().toString()
40-
4138
mongoose = require(`../../../versions/mongoose@${version}`).get()
4239

4340
connect()
@@ -58,7 +55,7 @@ describe('Plugin', () => {
5855
const PeerCat = mongoose.model('PeerCat', { name: String })
5956
new PeerCat({ name: 'PeerCat' }).save().catch(done)
6057
},
61-
'db', 'peer.service')
58+
dbName, 'peer.service')
6259

6360
it('should propagate context with write operations', () => {
6461
const Cat = mongoose.model('Cat1', { name: String })

0 commit comments

Comments
 (0)