@@ -221,28 +221,28 @@ mod tests {
221
221
222
222
#[ tokio:: test]
223
223
async fn connects_https ( ) {
224
- oneshot ( https_or_http_connector ( ) , https_uri ( ) )
224
+ oneshot ( https_or_http_connector ( ) , Scheme :: Https )
225
225
. await
226
226
. unwrap ( ) ;
227
227
}
228
228
229
229
#[ tokio:: test]
230
230
async fn connects_http ( ) {
231
- oneshot ( https_or_http_connector ( ) , http_uri ( ) )
231
+ oneshot ( https_or_http_connector ( ) , Scheme :: Http )
232
232
. await
233
233
. unwrap ( ) ;
234
234
}
235
235
236
236
#[ tokio:: test]
237
237
async fn connects_https_only ( ) {
238
- oneshot ( https_only_connector ( ) , https_uri ( ) )
238
+ oneshot ( https_only_connector ( ) , Scheme :: Https )
239
239
. await
240
240
. unwrap ( ) ;
241
241
}
242
242
243
243
#[ tokio:: test]
244
244
async fn enforces_https_only ( ) {
245
- let message = oneshot ( https_only_connector ( ) , http_uri ( ) )
245
+ let message = oneshot ( https_only_connector ( ) , Scheme :: Http )
246
246
. await
247
247
. unwrap_err ( )
248
248
. to_string ( ) ;
@@ -284,16 +284,21 @@ mod tests {
284
284
. with_no_client_auth ( ) ;
285
285
}
286
286
287
- async fn oneshot < S : Service < Uri > > ( mut service : S , req : Uri ) -> Result < S :: Response , S :: Error > {
287
+ async fn oneshot < S : Service < Uri > > (
288
+ mut service : S ,
289
+ scheme : Scheme ,
290
+ ) -> Result < S :: Response , S :: Error > {
288
291
poll_fn ( |cx| service. poll_ready ( cx) ) . await ?;
289
- service. call ( req) . await
290
- }
291
-
292
- fn https_uri ( ) -> Uri {
293
- Uri :: from_static ( "https://google.com" )
292
+ service
293
+ . call ( Uri :: from_static ( match scheme {
294
+ Scheme :: Https => "https://google.com" ,
295
+ Scheme :: Http => "http://google.com" ,
296
+ } ) )
297
+ . await
294
298
}
295
299
296
- fn http_uri ( ) -> Uri {
297
- Uri :: from_static ( "http://google.com" )
300
+ enum Scheme {
301
+ Https ,
302
+ Http ,
298
303
}
299
304
}
0 commit comments