File tree 2 files changed +30
-12
lines changed
test/integration/gh-issues
2 files changed +30
-12
lines changed Original file line number Diff line number Diff line change 7
7
* README.md file in the root directory of this source tree.
8
8
*/
9
9
10
- var util = require ( 'util' )
11
10
var Client = require ( './client' )
12
11
var defaults = require ( './defaults' )
13
12
var Connection = require ( './connection' )
14
13
var Pool = require ( 'pg-pool' )
15
- const checkConstructor = require ( './compat/check-constructor' )
16
14
17
15
const poolFactory = ( Client ) => {
18
- var BoundPool = function ( options ) {
19
- // eslint-disable-next-line no-eval
20
- checkConstructor ( 'pg.Pool' , 'PG-POOL-NEW' , ( ) => eval ( 'new.target' ) )
21
-
22
- var config = Object . assign ( { Client : Client } , options )
23
- return new Pool ( config )
16
+ return class BoundPool extends Pool {
17
+ constructor ( options ) {
18
+ var config = Object . assign ( { Client : Client } , options )
19
+ super ( config )
20
+ }
24
21
}
25
-
26
- util . inherits ( BoundPool , Pool )
27
-
28
- return BoundPool
29
22
}
30
23
31
24
var PG = function ( clientConstructor ) {
Original file line number Diff line number Diff line change
1
+
2
+ "use strict"
3
+ const helper = require ( './../test-helper' )
4
+ const assert = require ( 'assert' )
5
+
6
+ const suite = new helper . Suite ( )
7
+
8
+ suite . testAsync ( 'BoundPool can be subclassed' , async ( ) => {
9
+ const Pool = helper . pg . Pool ;
10
+ class SubPool extends Pool {
11
+
12
+ }
13
+ const subPool = new SubPool ( )
14
+ const client = await subPool . connect ( )
15
+ client . release ( )
16
+ await subPool . end ( )
17
+ assert ( subPool instanceof helper . pg . Pool )
18
+ } )
19
+
20
+ suite . test ( 'calling pg.Pool without new throws' , ( ) => {
21
+ const Pool = helper . pg . Pool ;
22
+ assert . throws ( ( ) => {
23
+ const pool = Pool ( )
24
+ } )
25
+ } )
You can’t perform that action at this time.
0 commit comments