1
1
'use strict' ;
2
2
3
3
const Config = require ( '../lib/Config' ) ;
4
- const TestUtils = require ( '../lib/TestUtils' ) ;
5
4
const { MongoClient } = require ( 'mongodb' ) ;
6
5
const databaseURI = 'mongodb://localhost:27017/' ;
7
6
const request = require ( '../lib/request' ) ;
@@ -20,22 +19,33 @@ const masterKeyOptions = {
20
19
json : true ,
21
20
} ;
22
21
22
+ const profileLevel = 2 ;
23
23
describe_only_db ( 'mongo' ) ( 'Parse.Query with comment testing' , ( ) => {
24
- beforeEach ( async ( ) => {
24
+ beforeAll ( async ( ) => {
25
25
config = Config . get ( 'test' ) ;
26
26
client = await MongoClient . connect ( databaseURI , {
27
27
useNewUrlParser : true ,
28
28
useUnifiedTopology : true ,
29
29
} ) ;
30
30
database = client . db ( 'parseServerMongoAdapterTestDatabase' ) ;
31
- const level = 2 ;
32
- const profiling = await database . command ( { profile : level } ) ;
33
- console . log ( `profiling ${ JSON . stringify ( profiling ) } ` ) ;
31
+ let profiler = await database . command ( { profile : 0 } ) ;
32
+ expect ( profiler . was ) . toEqual ( 0 ) ;
33
+ console . log ( `Disabling profiler : ${ profiler . was } ` ) ;
34
+ profiler = await database . command ( { profile : profileLevel } ) ;
35
+ profiler = await database . command ( { profile : - 1 } ) ;
36
+ console . log ( `Enabling profiler : ${ profiler . was } ` ) ;
37
+ profiler = await database . command ( { profile : - 1 } ) ;
38
+ expect ( profiler . was ) . toEqual ( profileLevel ) ;
39
+ } ) ;
40
+
41
+ beforeEach ( async ( ) => {
42
+ const profiler = await database . command ( { profile : - 1 } ) ;
43
+ expect ( profiler . was ) . toEqual ( profileLevel ) ;
34
44
} ) ;
35
45
36
- afterEach ( async ( ) => {
46
+ afterAll ( async ( ) => {
47
+ await database . command ( { profile : 0 } ) ;
37
48
await client . close ( ) ;
38
- await TestUtils . destroyAllDataPermanently ( false ) ;
39
49
} ) ;
40
50
41
51
it ( 'send comment with query through REST' , async ( ) => {
0 commit comments