@@ -9,21 +9,21 @@ use serde::{Deserialize, Serialize};
9
9
#[ test]
10
10
fn hello_world ( ) -> Result < ( ) , http_types:: Error > {
11
11
task:: block_on ( async {
12
- let bind = test_utils:: determine_port_to_bind ( ) . await ;
12
+ let port = test_utils:: find_port ( ) . await ;
13
13
let server = task:: spawn ( async move {
14
14
let mut app = tide:: new ( ) ;
15
15
app. at ( "/" ) . get ( |mut req : tide:: Request < ( ) > | async move {
16
16
assert_eq ! ( req. body_string( ) . await . unwrap( ) , "nori" . to_string( ) ) ;
17
17
let res = tide:: Response :: new ( StatusCode :: Ok ) . body_string ( "says hello" . to_string ( ) ) ;
18
18
Ok ( res)
19
19
} ) ;
20
- app. listen ( & bind ) . await ?;
20
+ app. listen ( & port ) . await ?;
21
21
Result :: < ( ) , http_types:: Error > :: Ok ( ( ) )
22
22
} ) ;
23
23
24
24
let client = task:: spawn ( async move {
25
25
task:: sleep ( Duration :: from_millis ( 100 ) ) . await ;
26
- let string = surf:: get ( format ! ( "http://{}" , bind ) )
26
+ let string = surf:: get ( format ! ( "http://{}" , port ) )
27
27
. body_string ( "nori" . to_string ( ) )
28
28
. recv_string ( )
29
29
. await ?;
@@ -38,18 +38,18 @@ fn hello_world() -> Result<(), http_types::Error> {
38
38
#[ test]
39
39
fn echo_server ( ) -> Result < ( ) , http_types:: Error > {
40
40
task:: block_on ( async {
41
- let bind = test_utils:: determine_port_to_bind ( ) . await ;
41
+ let port = test_utils:: find_port ( ) . await ;
42
42
let server = task:: spawn ( async move {
43
43
let mut app = tide:: new ( ) ;
44
44
app. at ( "/" ) . get ( |req| async move { Ok ( req) } ) ;
45
45
46
- app. listen ( & bind ) . await ?;
46
+ app. listen ( & port ) . await ?;
47
47
Result :: < ( ) , http_types:: Error > :: Ok ( ( ) )
48
48
} ) ;
49
49
50
50
let client = task:: spawn ( async move {
51
51
task:: sleep ( Duration :: from_millis ( 100 ) ) . await ;
52
- let string = surf:: get ( format ! ( "http://{}" , bind ) )
52
+ let string = surf:: get ( format ! ( "http://{}" , port ) )
53
53
. body_string ( "chashu" . to_string ( ) )
54
54
. recv_string ( )
55
55
. await ?;
@@ -69,7 +69,7 @@ fn json() -> Result<(), http_types::Error> {
69
69
}
70
70
71
71
task:: block_on ( async {
72
- let bind = test_utils:: determine_port_to_bind ( ) . await ;
72
+ let port = test_utils:: find_port ( ) . await ;
73
73
let server = task:: spawn ( async move {
74
74
let mut app = tide:: new ( ) ;
75
75
app. at ( "/" ) . get ( |mut req : tide:: Request < ( ) > | async move {
@@ -79,13 +79,13 @@ fn json() -> Result<(), http_types::Error> {
79
79
let res = tide:: Response :: new ( StatusCode :: Ok ) . body_json ( & counter) ?;
80
80
Ok ( res)
81
81
} ) ;
82
- app. listen ( & bind ) . await ?;
82
+ app. listen ( & port ) . await ?;
83
83
Result :: < ( ) , http_types:: Error > :: Ok ( ( ) )
84
84
} ) ;
85
85
86
86
let client = task:: spawn ( async move {
87
87
task:: sleep ( Duration :: from_millis ( 100 ) ) . await ;
88
- let counter: Counter = surf:: get ( format ! ( "http://{}" , & bind ) )
88
+ let counter: Counter = surf:: get ( format ! ( "http://{}" , & port ) )
89
89
. body_json ( & Counter { count : 0 } ) ?
90
90
. recv_json ( )
91
91
. await ?;
0 commit comments