@@ -14,12 +14,12 @@ async fn deno_serve_port_0() {
14
14
. arg ( "serve" )
15
15
. arg ( "--port" )
16
16
. arg ( "0" )
17
- . arg ( "./serve.ts" )
17
+ . arg ( "./serve/port_0 .ts" )
18
18
. stdout_piped ( )
19
19
. spawn ( )
20
20
. unwrap ( ) ;
21
21
let stdout = child. stdout . as_mut ( ) . unwrap ( ) ;
22
- let mut buffer = [ 0 ; 50 ] ;
22
+ let mut buffer = [ 0 ; 52 ] ;
23
23
let _read = stdout. read ( & mut buffer) . unwrap ( ) ;
24
24
let msg = std:: str:: from_utf8 ( & buffer) . unwrap ( ) ;
25
25
let port_regex = Regex :: new ( r"(\d+)" ) . unwrap ( ) ;
@@ -49,3 +49,46 @@ async fn deno_serve_port_0() {
49
49
child. kill ( ) . unwrap ( ) ;
50
50
child. wait ( ) . unwrap ( ) ;
51
51
}
52
+
53
+ #[ tokio:: test]
54
+ async fn deno_serve_no_args ( ) {
55
+ let mut child = util:: deno_cmd ( )
56
+ . current_dir ( util:: testdata_path ( ) )
57
+ . arg ( "serve" )
58
+ . arg ( "--port" )
59
+ . arg ( "0" )
60
+ . arg ( "./serve/no_args.ts" )
61
+ . stdout_piped ( )
62
+ . spawn ( )
63
+ . unwrap ( ) ;
64
+ let stdout = child. stdout . as_mut ( ) . unwrap ( ) ;
65
+ let mut buffer = [ 0 ; 52 ] ;
66
+ let _read = stdout. read ( & mut buffer) . unwrap ( ) ;
67
+ let msg = std:: str:: from_utf8 ( & buffer) . unwrap ( ) ;
68
+ let port_regex = Regex :: new ( r"(\d+)" ) . unwrap ( ) ;
69
+ let port = port_regex. find ( msg) . unwrap ( ) . as_str ( ) ;
70
+
71
+ let cert = reqwest:: Certificate :: from_pem ( include_bytes ! (
72
+ "../testdata/tls/RootCA.crt"
73
+ ) )
74
+ . unwrap ( ) ;
75
+
76
+ let client = reqwest:: Client :: builder ( )
77
+ . add_root_certificate ( cert)
78
+ . http2_prior_knowledge ( )
79
+ . build ( )
80
+ . unwrap ( ) ;
81
+
82
+ let res = client
83
+ . get ( & format ! ( "http://127.0.0.1:{port}" ) )
84
+ . send ( )
85
+ . await
86
+ . unwrap ( ) ;
87
+ assert_eq ! ( 200 , res. status( ) ) ;
88
+
89
+ let body = res. text ( ) . await . unwrap ( ) ;
90
+ assert_eq ! ( body, "deno serve with no args in fetch() works!" ) ;
91
+
92
+ child. kill ( ) . unwrap ( ) ;
93
+ child. wait ( ) . unwrap ( ) ;
94
+ }
0 commit comments