Skip to content

Commit 1420391

Browse files
committed
tests/util/test_app: Convert empty() fn to async
1 parent 90b0248 commit 1420391

34 files changed

+73
-74
lines changed

src/tests/authentication.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ static URL: &str = "/api/v1/me/updates";
99

1010
#[tokio::test(flavor = "multi_thread")]
1111
async fn anonymous_user_unauthorized() {
12-
let (_, anon) = TestApp::init().empty();
12+
let (_, anon) = TestApp::init().empty().await;
1313
let response: Response<()> = anon.get(URL).await;
1414

1515
assert_eq!(response.status(), StatusCode::FORBIDDEN);
@@ -18,7 +18,7 @@ async fn anonymous_user_unauthorized() {
1818

1919
#[tokio::test(flavor = "multi_thread")]
2020
async fn token_auth_cannot_find_token() {
21-
let (_, anon) = TestApp::init().empty();
21+
let (_, anon) = TestApp::init().empty().await;
2222
let mut request = anon.request_builder(Method::GET, URL);
2323
request.header(header::AUTHORIZATION, "cio1tkfake-token");
2424
let response: Response<()> = anon.run(request).await;
@@ -32,7 +32,7 @@ async fn token_auth_cannot_find_token() {
3232
// the database, it is not possible to implement this same test for a token.
3333
#[tokio::test(flavor = "multi_thread")]
3434
async fn cookie_auth_cannot_find_user() {
35-
let (app, anon) = TestApp::init().empty();
35+
let (app, anon) = TestApp::init().empty().await;
3636

3737
let session_key = app.as_inner().session_key();
3838
let cookie = encode_session_header(session_key, -1);

src/tests/github_secret_scanning.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ async fn github_secret_alert_for_unknown_token() {
211211

212212
#[tokio::test(flavor = "multi_thread")]
213213
async fn github_secret_alert_invalid_signature_fails() {
214-
let (_, anon) = TestApp::init().with_github(github_mock()).empty();
214+
let (_, anon) = TestApp::init().with_github(github_mock()).empty().await;
215215

216216
// No headers or request body
217217
let request = anon.post_request(URL);

src/tests/issues/issue2736.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use insta::assert_snapshot;
99
/// See <https://github.com/rust-lang/crates.io/issues/2736>.
1010
#[tokio::test(flavor = "multi_thread")]
1111
async fn test_issue_2736() -> anyhow::Result<()> {
12-
let (app, _) = TestApp::full().empty();
12+
let (app, _) = TestApp::full().empty().await;
1313
let mut conn = app.db_conn();
1414

1515
// - A user had a GitHub account named, let's say, `foo`

src/tests/middleware/head.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use http::{Method, StatusCode};
33

44
#[tokio::test(flavor = "multi_thread")]
55
async fn head_method_works() {
6-
let (_, anon) = TestApp::init().empty();
6+
let (_, anon) = TestApp::init().empty().await;
77

88
let req = anon.request_builder(Method::HEAD, "/api/v1/summary");
99
let res = anon.run::<()>(req).await;
@@ -13,7 +13,7 @@ async fn head_method_works() {
1313

1414
#[tokio::test(flavor = "multi_thread")]
1515
async fn head_method_works_for_404() {
16-
let (_, anon) = TestApp::init().empty();
16+
let (_, anon) = TestApp::init().empty().await;
1717

1818
let req = anon.request_builder(Method::HEAD, "/unknown");
1919
let res = anon.run::<()>(req).await;

src/tests/not_found_error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use insta::assert_snapshot;
44

55
#[tokio::test(flavor = "multi_thread")]
66
async fn visiting_unknown_route_returns_404() {
7-
let (_, anon) = TestApp::init().empty();
7+
let (_, anon) = TestApp::init().empty().await;
88

99
let response = anon.get::<()>("/does-not-exist").await;
1010
assert_eq!(response.status(), StatusCode::NOT_FOUND);
@@ -13,7 +13,7 @@ async fn visiting_unknown_route_returns_404() {
1313

1414
#[tokio::test(flavor = "multi_thread")]
1515
async fn visiting_unknown_api_route_returns_404() {
16-
let (_, anon) = TestApp::init().empty();
16+
let (_, anon) = TestApp::init().empty().await;
1717

1818
let response = anon.get::<()>("/api/v1/does-not-exist").await;
1919
assert_eq!(response.status(), StatusCode::NOT_FOUND);

src/tests/read_only_mode.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ async fn can_hit_read_only_endpoints_in_read_only_mode() {
1111
.with_config(|config| {
1212
config.db.primary.read_only_mode = true;
1313
})
14-
.empty();
14+
.empty()
15+
.await;
1516

1617
let response = anon.get::<()>("/api/v1/crates").await;
1718
assert_eq!(response.status(), StatusCode::OK);

src/tests/routes/categories/get.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use serde_json::Value;
99

1010
#[tokio::test(flavor = "multi_thread")]
1111
async fn show() {
12-
let (app, anon) = TestApp::init().empty();
12+
let (app, anon) = TestApp::init().empty().await;
1313
let mut conn = app.db_conn();
1414

1515
let url = "/api/v1/categories/foo-bar";

src/tests/routes/categories/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use serde_json::Value;
88

99
#[tokio::test(flavor = "multi_thread")]
1010
async fn index() {
11-
let (app, anon) = TestApp::init().empty();
11+
let (app, anon) = TestApp::init().empty().await;
1212
let mut conn = app.async_db_conn().await;
1313

1414
// List 0 categories if none exist

src/tests/routes/category_slugs/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use serde_json::Value;
88

99
#[tokio::test(flavor = "multi_thread")]
1010
async fn category_slugs_returns_all_slugs_in_alphabetical_order() {
11-
let (app, anon) = TestApp::init().empty();
11+
let (app, anon) = TestApp::init().empty().await;
1212
let mut conn = app.async_db_conn().await;
1313

1414
let cats = vec![

src/tests/routes/crates/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::sync::LazyLock;
1313

1414
#[tokio::test(flavor = "multi_thread")]
1515
async fn index() {
16-
let (app, anon) = TestApp::init().empty();
16+
let (app, anon) = TestApp::init().empty().await;
1717
let mut conn = app.db_conn();
1818

1919
for json in search_both(&anon, "").await {

0 commit comments

Comments
 (0)