@@ -32,6 +32,7 @@ const USERDATA_FILES = ['json', 'xlsx', 'csv', 'parquet', 'jsonl'];
3232const PORT = '9799' ;
3333
3434let server ;
35+ // Kill the existing server if it wasn't killed correctly already.
3536beforeAll ( async ( ) => {
3637 // TODO: port this logic to other platforms...
3738 if ( process . platform === 'linux' ) {
@@ -44,6 +45,7 @@ beforeAll(async () => {
4445 }
4546 }
4647
48+ // Start a new server for all tests
4749 server = spawn ( 'python3' , [ '-m' , 'http.server' , PORT ] ) ;
4850 let ready = false ;
4951 server . on ( 'spawn' , ( ) => {
@@ -206,43 +208,69 @@ for (const subprocessName of RUNNERS) {
206208 }
207209
208210 if ( process . platform === 'linux' ) {
209- describe (
210- 'eval file over server via ' +
211- ( subprocessName ? subprocessName . go || subprocessName . node : 'memory' ) ,
212- ( ) => {
213- test ( 'correct result' , ( ) => {
214- const server = new ServerInfo ( {
215- address : 'localhost' ,
216- type : 'private-key' ,
217- } ) ;
218- const hp = new HTTPPanelInfo (
219- '' ,
220- new HTTPConnectorInfo ( '' , 'http://localhost:9799/testdata/unknown' )
221- ) ;
222- hp . serverId = server . id ;
211+ describe ( 'http with headers' , ( ) => {
212+ test ( 'correct result' , ( ) => {
213+ const hp = new HTTPPanelInfo (
214+ '' ,
215+ new HTTPConnectorInfo ( '' , 'http://localhost:9799/testdata/unknown' , [
216+ { name : 'X-Test' , value : 'OK' } ,
217+ ] )
218+ ) ;
223219
224- const servers = [ server ] ;
225- const panels = [ hp ] ;
220+ const panels = [ hp ] ;
226221
227- return withSavedPanels (
228- panels ,
229- ( project ) => {
230- // Grab result
231- const value = JSON . parse (
232- fs
233- . readFileSync (
234- getProjectResultsFile ( project . projectName ) + hp . id
235- )
236- . toString ( )
237- ) ;
222+ return withSavedPanels (
223+ panels ,
224+ ( project ) => {
225+ // Grab result
226+ const value = JSON . parse (
227+ fs
228+ . readFileSync (
229+ getProjectResultsFile ( project . projectName ) + hp . id
230+ )
231+ . toString ( )
232+ ) ;
238233
239- expect ( value ) . toEqual ( 'hey this is unknown' ) ;
240- } ,
241- { evalPanels : true , subprocessName, servers }
242- ) ;
243- } , 30_000 ) ;
244- }
245- ) ;
234+ expect ( value ) . toEqual ( 'hey this is unknown' ) ;
235+ } ,
236+ { evalPanels : true , subprocessName }
237+ ) ;
238+ } ) ;
239+ } ) ;
240+
241+ describe ( 'eval http over server via ' + subprocessName . go , ( ) => {
242+ test ( 'correct result' , ( ) => {
243+ const server = new ServerInfo ( {
244+ address : 'localhost' ,
245+ type : 'private-key' ,
246+ } ) ;
247+ const hp = new HTTPPanelInfo (
248+ '' ,
249+ new HTTPConnectorInfo ( '' , 'http://localhost:9799/testdata/unknown' )
250+ ) ;
251+ hp . serverId = server . id ;
252+
253+ const servers = [ server ] ;
254+ const panels = [ hp ] ;
255+
256+ return withSavedPanels (
257+ panels ,
258+ ( project ) => {
259+ // Grab result
260+ const value = JSON . parse (
261+ fs
262+ . readFileSync (
263+ getProjectResultsFile ( project . projectName ) + hp . id
264+ )
265+ . toString ( )
266+ ) ;
267+
268+ expect ( value ) . toEqual ( 'hey this is unknown' ) ;
269+ } ,
270+ { evalPanels : true , subprocessName, servers }
271+ ) ;
272+ } , 30_000 ) ;
273+ } ) ;
246274 }
247275}
248276
0 commit comments