@@ -8,152 +8,152 @@ const pem = require('https-pem')
88const fs = require ( 'node:fs' )
99const { tspl } = require ( '@matteo.collina/tspl' )
1010
11- if ( process . platform !== 'win32' ) {
12- test ( 'http unix get' , async ( t ) => {
13- let client
14- const p = tspl ( t , { plan : 7 } )
15-
16- const server = http . createServer ( ( req , res ) => {
17- p . equal ( '/' , req . url )
18- p . equal ( 'GET' , req . method )
19- p . equal ( 'localhost' , req . headers . host )
20- res . setHeader ( 'Content-Type' , 'text/plain' )
21- res . end ( 'hello' )
22- } )
11+ const skip = process . platform === 'win32'
12+
13+ test ( 'http unix get' , { skip } , async ( t ) => {
14+ let client
15+ const p = tspl ( t , { plan : 7 } )
16+
17+ const server = http . createServer ( ( req , res ) => {
18+ p . equal ( '/' , req . url )
19+ p . equal ( 'GET' , req . method )
20+ p . equal ( 'localhost' , req . headers . host )
21+ res . setHeader ( 'Content-Type' , 'text/plain' )
22+ res . end ( 'hello' )
23+ } )
2324
24- t . after ( ( ) => {
25- server . close ( )
26- client . close ( )
27- } )
25+ t . after ( ( ) => {
26+ server . close ( )
27+ client . close ( )
28+ } )
2829
29- try {
30- fs . unlinkSync ( '/var/tmp/test3.sock' )
31- } catch ( err ) {
30+ try {
31+ fs . unlinkSync ( '/var/tmp/test3.sock' )
32+ } catch ( err ) {
3233
33- }
34+ }
3435
35- server . listen ( '/var/tmp/test3.sock' , ( ) => {
36- client = new Client ( {
37- hostname : 'localhost' ,
38- protocol : 'http:'
39- } , {
40- socketPath : '/var/tmp/test3.sock'
41- } )
36+ server . listen ( '/var/tmp/test3.sock' , ( ) => {
37+ client = new Client ( {
38+ hostname : 'localhost' ,
39+ protocol : 'http:'
40+ } , {
41+ socketPath : '/var/tmp/test3.sock'
42+ } )
4243
43- client . request ( { path : '/' , method : 'GET' } , ( err , data ) => {
44- p . ifError ( err )
45- const { statusCode, headers, body } = data
46- p . equal ( statusCode , 200 )
47- p . equal ( headers [ 'content-type' ] , 'text/plain' )
48- const bufs = [ ]
49- body . on ( 'data' , ( buf ) => {
50- bufs . push ( buf )
51- } )
52- body . on ( 'end' , ( ) => {
53- p . equal ( 'hello' , Buffer . concat ( bufs ) . toString ( 'utf8' ) )
54- } )
44+ client . request ( { path : '/' , method : 'GET' } , ( err , data ) => {
45+ p . ifError ( err )
46+ const { statusCode, headers, body } = data
47+ p . equal ( statusCode , 200 )
48+ p . equal ( headers [ 'content-type' ] , 'text/plain' )
49+ const bufs = [ ]
50+ body . on ( 'data' , ( buf ) => {
51+ bufs . push ( buf )
52+ } )
53+ body . on ( 'end' , ( ) => {
54+ p . equal ( 'hello' , Buffer . concat ( bufs ) . toString ( 'utf8' ) )
5555 } )
5656 } )
57-
58- await p . completed
5957 } )
6058
61- test ( 'http unix get pool' , async ( t ) => {
62- let client
63- const p = tspl ( t , { plan : 7 } )
59+ await p . completed
60+ } )
6461
65- const server = http . createServer ( ( req , res ) => {
66- p . equal ( '/' , req . url )
67- p . equal ( 'GET' , req . method )
68- p . equal ( 'localhost' , req . headers . host )
69- res . setHeader ( 'Content-Type' , 'text/plain' )
70- res . end ( 'hello' )
71- } )
62+ test ( 'http unix get pool' , { skip } , async ( t ) => {
63+ let client
64+ const p = tspl ( t , { plan : 7 } )
7265
73- t . after ( ( ) => {
74- server . close ( )
75- client . close ( )
76- } )
66+ const server = http . createServer ( ( req , res ) => {
67+ p . equal ( '/' , req . url )
68+ p . equal ( 'GET' , req . method )
69+ p . equal ( 'localhost' , req . headers . host )
70+ res . setHeader ( 'Content-Type' , 'text/plain' )
71+ res . end ( 'hello' )
72+ } )
7773
78- try {
79- fs . unlinkSync ( '/var/tmp/test3.sock' )
80- } catch ( err ) {
74+ t . after ( ( ) => {
75+ server . close ( )
76+ client . close ( )
77+ } )
8178
82- }
79+ try {
80+ fs . unlinkSync ( '/var/tmp/test3.sock' )
81+ } catch ( err ) {
8382
84- server . listen ( '/var/tmp/test3.sock' , ( ) => {
85- client = new Pool ( {
86- hostname : 'localhost' ,
87- protocol : 'http:'
88- } , {
89- socketPath : '/var/tmp/test3.sock'
90- } )
83+ }
9184
92- client . request ( { path : '/' , method : 'GET' } , ( err , data ) => {
93- p . ifError ( err )
94- const { statusCode, headers, body } = data
95- p . equal ( statusCode , 200 )
96- p . equal ( headers [ 'content-type' ] , 'text/plain' )
97- const bufs = [ ]
98- body . on ( 'data' , ( buf ) => {
99- bufs . push ( buf )
100- } )
101- body . on ( 'end' , ( ) => {
102- p . equal ( 'hello' , Buffer . concat ( bufs ) . toString ( 'utf8' ) )
103- } )
104- } )
85+ server . listen ( '/var/tmp/test3.sock' , ( ) => {
86+ client = new Pool ( {
87+ hostname : 'localhost' ,
88+ protocol : 'http:'
89+ } , {
90+ socketPath : '/var/tmp/test3.sock'
10591 } )
10692
107- await p . completed
93+ client . request ( { path : '/' , method : 'GET' } , ( err , data ) => {
94+ p . ifError ( err )
95+ const { statusCode, headers, body } = data
96+ p . equal ( statusCode , 200 )
97+ p . equal ( headers [ 'content-type' ] , 'text/plain' )
98+ const bufs = [ ]
99+ body . on ( 'data' , ( buf ) => {
100+ bufs . push ( buf )
101+ } )
102+ body . on ( 'end' , ( ) => {
103+ p . equal ( 'hello' , Buffer . concat ( bufs ) . toString ( 'utf8' ) )
104+ } )
105+ } )
108106 } )
109107
110- test ( 'https get with tls opts' , async ( t ) => {
111- let client
112- const p = tspl ( t , { plan : 6 } )
108+ await p . completed
109+ } )
113110
114- const server = https . createServer ( pem , ( req , res ) => {
115- p . equal ( '/' , req . url )
116- p . equal ( 'GET' , req . method )
117- res . setHeader ( 'content-type' , 'text/plain' )
118- res . end ( 'hello' )
119- } )
111+ test ( 'https get with tls opts' , { skip } , async ( t ) => {
112+ let client
113+ const p = tspl ( t , { plan : 6 } )
120114
121- t . after ( ( ) => {
122- server . close ( )
123- client . close ( )
115+ const server = https . createServer ( pem , ( req , res ) => {
116+ p . equal ( '/' , req . url )
117+ p . equal ( 'GET' , req . method )
118+ res . setHeader ( 'content-type' , 'text/plain' )
119+ res . end ( 'hello' )
120+ } )
121+
122+ t . after ( ( ) => {
123+ server . close ( )
124+ client . close ( )
125+ } )
126+
127+ try {
128+ fs . unlinkSync ( '/var/tmp/test3.sock' )
129+ } catch ( err ) {
130+
131+ }
132+
133+ server . listen ( '/var/tmp/test3.sock' , ( ) => {
134+ client = new Client ( {
135+ hostname : 'localhost' ,
136+ protocol : 'https:'
137+ } , {
138+ socketPath : '/var/tmp/test3.sock' ,
139+ tls : {
140+ rejectUnauthorized : false
141+ }
124142 } )
125143
126- try {
127- fs . unlinkSync ( '/var/tmp/test3.sock' )
128- } catch ( err ) {
129-
130- }
131-
132- server . listen ( '/var/tmp/test3.sock' , ( ) => {
133- client = new Client ( {
134- hostname : 'localhost' ,
135- protocol : 'https:'
136- } , {
137- socketPath : '/var/tmp/test3.sock' ,
138- tls : {
139- rejectUnauthorized : false
140- }
144+ client . request ( { path : '/' , method : 'GET' } , ( err , data ) => {
145+ p . ifError ( err )
146+ const { statusCode, headers, body } = data
147+ p . equal ( statusCode , 200 )
148+ p . equal ( headers [ 'content-type' ] , 'text/plain' )
149+ const bufs = [ ]
150+ body . on ( 'data' , ( buf ) => {
151+ bufs . push ( buf )
141152 } )
142-
143- client . request ( { path : '/' , method : 'GET' } , ( err , data ) => {
144- p . ifError ( err )
145- const { statusCode, headers, body } = data
146- p . equal ( statusCode , 200 )
147- p . equal ( headers [ 'content-type' ] , 'text/plain' )
148- const bufs = [ ]
149- body . on ( 'data' , ( buf ) => {
150- bufs . push ( buf )
151- } )
152- body . on ( 'end' , ( ) => {
153- p . equal ( 'hello' , Buffer . concat ( bufs ) . toString ( 'utf8' ) )
154- } )
153+ body . on ( 'end' , ( ) => {
154+ p . equal ( 'hello' , Buffer . concat ( bufs ) . toString ( 'utf8' ) )
155155 } )
156156 } )
157- await p . completed
158157 } )
159- }
158+ await p . completed
159+ } )
0 commit comments