@@ -6,6 +6,14 @@ import { EJSON } from 'bson';
6
6
import path from 'path' ;
7
7
import { once } from 'events' ;
8
8
9
+ let hostport : string ;
10
+ before ( ( ) => {
11
+ if ( ! process . env . MONGODB_HOSTPORT ) {
12
+ throw new Error ( 'MONGODB_HOSTPORT not set' ) ;
13
+ }
14
+ hostport = process . env . MONGODB_HOSTPORT ;
15
+ } ) ;
16
+
9
17
describe ( 'Proxy' , function ( ) {
10
18
this . timeout ( 10_000 ) ;
11
19
@@ -16,9 +24,9 @@ describe('Proxy', function() {
16
24
17
25
beforeEach ( async ( ) => {
18
26
events = [ ] ;
19
- proxy = new Proxy ( { host : 'localhost' , port : 27018 } ) ;
27
+ proxy = new Proxy ( { host : hostport . split ( ':' ) [ 0 ] , port : + hostport . split ( ':' ) [ 1 ] } ) ;
20
28
proxy . on ( 'newConnection' , ( conn : any ) => {
21
- conn . on ( 'connectionEnded' , ( source : string ) => events . push ( { ev : 'connecionEnded ' , source } ) ) ;
29
+ conn . on ( 'connectionEnded' , ( source : string ) => events . push ( { ev : 'connectionEnded ' , source } ) ) ;
22
30
conn . on ( 'connectionError' , ( source : string , err : Error ) => events . push ( { ev : 'connectionError' , source, err } ) ) ;
23
31
conn . on ( 'message' , ( source : string , msg : any ) => events . push ( { ev : 'message' , source, msg } ) ) ;
24
32
conn . on ( 'parseError' , ( source : string , err : Error ) => events . push ( { ev : 'parseError' , source, err } ) ) ;
@@ -62,7 +70,7 @@ describe('bin', function() {
62
70
proc = childProcess . spawn ( 'ts-node' , [
63
71
'-P' , path . join ( __dirname , '..' , 'tsconfig.json' ) ,
64
72
path . join ( __dirname , '..' , 'src' , 'cli.ts' ) ,
65
- 'localhost:27018' , 'localhost:0'
73
+ hostport , 'localhost:0'
66
74
] , { stdio : 'pipe' } ) ;
67
75
port = 0 ;
68
76
await new Promise < void > ( ( resolve ) => {
@@ -107,7 +115,7 @@ describe('bin', function() {
107
115
'-P' , path . join ( __dirname , '..' , 'tsconfig.json' ) ,
108
116
path . join ( __dirname , '..' , 'src' , 'cli.ts' ) ,
109
117
'--ndjson' ,
110
- 'localhost:27018' , 'localhost:0'
118
+ hostport , 'localhost:0'
111
119
] , { stdio : 'pipe' } ) ;
112
120
port = 0 ;
113
121
await new Promise < void > ( ( resolve ) => {
0 commit comments