1
1
'use strict' ;
2
2
3
3
const mysql = require ( '../..' ) ;
4
- const test = require ( 'utest' ) ;
5
4
const assert = require ( 'assert' ) ;
6
- const common = require ( '../common' ) ;
5
+ const common = require ( '../common.test.cjs ' ) ;
7
6
8
7
const poolConfig = common . getConfig ( ) ;
9
8
@@ -15,33 +14,34 @@ const poolWithAcquireTimeout = new mysql.createPool({
15
14
} ) ;
16
15
17
16
poolWithAcquireTimeout . getConnection ( ( err , c1 ) => {
17
+
18
18
assert . equal ( ! ! c1 , true ) ;
19
19
assert . ifError ( err ) ;
20
+
20
21
poolWithAcquireTimeout . getConnection ( ( err , c2 ) => {
22
+
21
23
assert . ifError ( err ) ;
22
24
assert . equal ( ! ! c2 , true ) ;
25
+
23
26
const C3_STARTED_AT = Date . now ( ) ;
27
+
24
28
poolWithAcquireTimeout . getConnection ( ( e3 , c3 ) => {
25
29
const C3_DONE_AT = Date . now ( ) ;
30
+ assert . equal ( C3_DONE_AT - C3_STARTED_AT >= ACQUIRE_TIMEOUT , true ) ;
31
+ assert . equal ( C3_DONE_AT - C3_STARTED_AT < ACQUIRE_TIMEOUT * 2 , true ) ;
26
32
27
- poolWithAcquireTimeout . releaseConnection ( c1 ) ;
33
+ assert . notEqual ( e3 , null ) ;
34
+ assert . equal ( ! c3 , true ) ;
35
+ c1 . release ( ) ;
28
36
29
37
poolWithAcquireTimeout . getConnection ( ( e4 , c4 ) => {
30
38
31
- test ( 'Pool With Acquire Timeout' , {
32
- 'timeout of pool is full' : ( ) => {
33
- assert . equal ( e3 !== null , true ) ;
34
- assert . equal ( ! c3 , true ) ;
35
- assert . equal ( C3_DONE_AT - C3_STARTED_AT >= ACQUIRE_TIMEOUT , true ) ;
36
- assert . equal ( C3_DONE_AT - C3_STARTED_AT < ACQUIRE_TIMEOUT * 2 , true ) ;
37
- } ,
38
- 'ok if pool is not full' : ( ) => {
39
- assert . equal ( e4 === null , true ) ;
40
- assert . equal ( ! ! c4 , true ) ;
41
- }
42
- } ) ;
43
-
44
- poolWithAcquireTimeout . releaseConnection ( c4 ) ;
39
+ assert . equal ( e4 , null ) ;
40
+ assert . equal ( ! ! c4 , true ) ;
41
+
42
+ c4 . release ( ) ;
43
+ c2 . release ( ) ;
44
+ poolWithAcquireTimeout . end ( ) ;
45
45
} ) ;
46
46
} ) ;
47
47
} ) ;
0 commit comments