Skip to content

Commit a38dfae

Browse files
committed
tests: inline trivial helper functions
1 parent 515822c commit a38dfae

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/connector.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,28 +221,28 @@ mod tests {
221221

222222
#[tokio::test]
223223
async fn connects_https() {
224-
oneshot(https_or_http_connector(), https_uri())
224+
oneshot(https_or_http_connector(), Scheme::Https)
225225
.await
226226
.unwrap();
227227
}
228228

229229
#[tokio::test]
230230
async fn connects_http() {
231-
oneshot(https_or_http_connector(), http_uri())
231+
oneshot(https_or_http_connector(), Scheme::Http)
232232
.await
233233
.unwrap();
234234
}
235235

236236
#[tokio::test]
237237
async fn connects_https_only() {
238-
oneshot(https_only_connector(), https_uri())
238+
oneshot(https_only_connector(), Scheme::Https)
239239
.await
240240
.unwrap();
241241
}
242242

243243
#[tokio::test]
244244
async fn enforces_https_only() {
245-
let message = oneshot(https_only_connector(), http_uri())
245+
let message = oneshot(https_only_connector(), Scheme::Http)
246246
.await
247247
.unwrap_err()
248248
.to_string();
@@ -284,16 +284,21 @@ mod tests {
284284
.with_no_client_auth();
285285
}
286286

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> {
288291
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
294298
}
295299

296-
fn http_uri() -> Uri {
297-
Uri::from_static("http://google.com")
300+
enum Scheme {
301+
Https,
302+
Http,
298303
}
299304
}

0 commit comments

Comments
 (0)