3
3
const semver = require ( 'semver' )
4
4
const agent = require ( '../../dd-trace/test/plugins/agent' )
5
5
const { NODE_MAJOR } = require ( '../../../version' )
6
+ const id = require ( '../../dd-trace/src/id' )
6
7
7
8
describe ( 'Plugin' , ( ) => {
8
- let id
9
9
let tracer
10
- let dbName
10
+ const dbName = id ( ) . toString ( )
11
11
12
12
describe ( 'mongoose' , ( ) => {
13
13
withVersions ( 'mongoose' , [ 'mongoose' ] , ( version ) => {
@@ -19,10 +19,10 @@ describe('Plugin', () => {
19
19
// This needs to be called synchronously right before each test to make
20
20
// sure a connection is not already established and the request is added
21
21
// to the queue.
22
- async function connect ( ) {
22
+ function connect ( ) {
23
23
// mongoose.connect('mongodb://username:password@host:port/database?options...');
24
24
// 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 } ` , {
26
26
useNewUrlParser : true ,
27
27
useUnifiedTopology : true
28
28
} )
@@ -33,11 +33,8 @@ describe('Plugin', () => {
33
33
} )
34
34
35
35
before ( ( ) => {
36
- id = require ( '../../dd-trace/src/id' )
37
36
tracer = require ( '../../dd-trace' )
38
37
39
- dbName = id ( ) . toString ( )
40
-
41
38
mongoose = require ( `../../../versions/mongoose@${ version } ` ) . get ( )
42
39
43
40
connect ( )
@@ -58,7 +55,7 @@ describe('Plugin', () => {
58
55
const PeerCat = mongoose . model ( 'PeerCat' , { name : String } )
59
56
new PeerCat ( { name : 'PeerCat' } ) . save ( ) . catch ( done )
60
57
} ,
61
- 'db' , 'peer.service' )
58
+ dbName , 'peer.service' )
62
59
63
60
it ( 'should propagate context with write operations' , ( ) => {
64
61
const Cat = mongoose . model ( 'Cat1' , { name : String } )
0 commit comments