File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
packages/pg-query-stream/test Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ import helper from "./helper" ;
2
+ import QueryStream from "../src" ;
3
+ import pg from "pg" ;
4
+
5
+
6
+ describe ( "Pool Query-Stream" , function ( ) {
7
+
8
+ it ( 'releases pool connection after end of query stream' , async function ( ) {
9
+ const pool = new pg . Pool ( ) ;
10
+ // const client = await pool.connect();
11
+ const query = new QueryStream ( 'SELECT NOW()' ) ;
12
+ const stream = pool . query ( query ) ;
13
+
14
+ query . on ( 'end' , async ( res ) => {
15
+ console . log ( 'query stream ended' ) ;
16
+ } ) ;
17
+
18
+ // bellow code raising error as stream .on is not a function
19
+ console . log ( await stream ) ; // this never gets resolved;
20
+ stream . on ( 'end' , async ( res ) => {
21
+ console . log ( res ) ;
22
+ await pool . end ( ) ;
23
+ console . log ( 'stream ended' ) ;
24
+ await Promise . resolve ( ) ;
25
+ } )
26
+
27
+ } )
28
+
29
+ } )
You can’t perform that action at this time.
0 commit comments