Skip to content

Commit 5f0fe61

Browse files
committed
tests/util/test_app: Convert with_token() fn to async
1 parent 3a7ad5c commit 5f0fe61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+184
-154
lines changed

src/tests/dump_db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static PATH_DATE_RE: LazyLock<Regex> =
1515

1616
#[tokio::test(flavor = "multi_thread")]
1717
async fn test_dump_db_job() {
18-
let (app, _, _, token) = TestApp::full().with_token();
18+
let (app, _, _, token) = TestApp::full().with_token().await;
1919
let mut conn = app.db_conn();
2020

2121
CrateBuilder::new("test-crate", token.as_model().user_id).expect_build(&mut conn);

src/tests/github_secret_scanning.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ fn github_mock() -> MockGitHubClient {
4141

4242
#[tokio::test(flavor = "multi_thread")]
4343
async fn github_secret_alert_revokes_token() {
44-
let (app, anon, user, token) = TestApp::init().with_github(github_mock()).with_token();
44+
let (app, anon, user, token) = TestApp::init()
45+
.with_github(github_mock())
46+
.with_token()
47+
.await;
4548
let mut conn = app.async_db_conn().await;
4649

4750
// Ensure no emails were sent up to this point
@@ -99,7 +102,10 @@ async fn github_secret_alert_revokes_token() {
99102

100103
#[tokio::test(flavor = "multi_thread")]
101104
async fn github_secret_alert_for_revoked_token() {
102-
let (app, anon, user, token) = TestApp::init().with_github(github_mock()).with_token();
105+
let (app, anon, user, token) = TestApp::init()
106+
.with_github(github_mock())
107+
.with_token()
108+
.await;
103109
let mut conn = app.async_db_conn().await;
104110

105111
// Ensure no emails were sent up to this point
@@ -160,7 +166,10 @@ async fn github_secret_alert_for_revoked_token() {
160166

161167
#[tokio::test(flavor = "multi_thread")]
162168
async fn github_secret_alert_for_unknown_token() {
163-
let (app, anon, user, token) = TestApp::init().with_github(github_mock()).with_token();
169+
let (app, anon, user, token) = TestApp::init()
170+
.with_github(github_mock())
171+
.with_token()
172+
.await;
164173
let mut conn = app.async_db_conn().await;
165174

166175
// Ensure no emails were sent up to this point

src/tests/issues/issue1205.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ use insta::assert_snapshot;
99
async fn test_issue_1205() -> anyhow::Result<()> {
1010
const CRATE_NAME: &str = "deepspeech-sys";
1111

12-
let (app, _, _, user) = TestApp::full().with_github(github_mock()).with_token();
12+
let (app, _, _, user) = TestApp::full()
13+
.with_github(github_mock())
14+
.with_token()
15+
.await;
1316

1417
let mut conn = app.db_conn();
1518

src/tests/krate/following.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ async fn test_api_token_auth() {
117117
const CRATE_TO_FOLLOW: &str = "some_crate_to_follow";
118118
const CRATE_NOT_TO_FOLLOW: &str = "another_crate";
119119

120-
let (app, _, user, token) = TestApp::init().with_token();
120+
let (app, _, user, token) = TestApp::init().with_token().await;
121121
let mut conn = app.db_conn();
122122
let api_token = token.as_model();
123123

src/tests/krate/publish/audit_action.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ async fn publish_records_an_audit_action() {
66
use crate::tests::builders::PublishBuilder;
77
use crate::tests::util::{RequestHelper, TestApp};
88

9-
let (app, anon, _, token) = TestApp::full().with_token();
9+
let (app, anon, _, token) = TestApp::full().with_token().await;
1010

1111
let mut conn = app.db_conn();
1212
assert!(VersionOwnerAction::all(&mut conn).unwrap().is_empty());

src/tests/krate/publish/auth.rs

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

1010
#[tokio::test(flavor = "multi_thread")]
1111
async fn new_wrong_token() {
12-
let (app, anon, _, token) = TestApp::full().with_token();
12+
let (app, anon, _, token) = TestApp::full().with_token().await;
1313
let mut conn = app.async_db_conn().await;
1414

1515
// Try to publish without a token

src/tests/krate/publish/basics.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async fn new_krate() {
4343

4444
#[tokio::test(flavor = "multi_thread")]
4545
async fn new_krate_with_token() {
46-
let (app, _, _, token) = TestApp::full().with_token();
46+
let (app, _, _, token) = TestApp::full().with_token().await;
4747

4848
let crate_to_publish = PublishBuilder::new("foo_new", "1.0.0");
4949
let response = token.publish_crate(crate_to_publish).await;
@@ -64,7 +64,7 @@ async fn new_krate_with_token() {
6464

6565
#[tokio::test(flavor = "multi_thread")]
6666
async fn new_krate_weird_version() {
67-
let (app, _, _, token) = TestApp::full().with_token();
67+
let (app, _, _, token) = TestApp::full().with_token().await;
6868

6969
let crate_to_publish = PublishBuilder::new("foo_weird", "0.0.0-pre");
7070
let response = token.publish_crate(crate_to_publish).await;
@@ -85,7 +85,7 @@ async fn new_krate_weird_version() {
8585

8686
#[tokio::test(flavor = "multi_thread")]
8787
async fn new_krate_twice() {
88-
let (app, _, _, token) = TestApp::full().with_token();
88+
let (app, _, _, token) = TestApp::full().with_token().await;
8989

9090
let crate_to_publish = PublishBuilder::new("foo_twice", "0.99.0");
9191
token.publish_crate(crate_to_publish).await.good();
@@ -116,7 +116,7 @@ async fn new_krate_twice() {
116116
// The primary purpose is to verify that the `default_version` we provide is as expected.
117117
#[tokio::test(flavor = "multi_thread")]
118118
async fn new_krate_twice_alt() {
119-
let (app, _, _, token) = TestApp::full().with_token();
119+
let (app, _, _, token) = TestApp::full().with_token().await;
120120

121121
let crate_to_publish =
122122
PublishBuilder::new("foo_twice", "2.0.0").description("2.0.0 description");
@@ -145,7 +145,7 @@ async fn new_krate_twice_alt() {
145145

146146
#[tokio::test(flavor = "multi_thread")]
147147
async fn new_krate_duplicate_version() {
148-
let (app, _, user, token) = TestApp::full().with_token();
148+
let (app, _, user, token) = TestApp::full().with_token().await;
149149
let mut conn = app.db_conn();
150150

151151
// Insert a crate directly into the database and then we'll try to publish the same version

src/tests/krate/publish/build_metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use insta::assert_json_snapshot;
55
use serde_json::json;
66

77
async fn version_with_build_metadata(v1: &str, v2: &str, expected_error: &str) {
8-
let (_app, _anon, _cookie, token) = TestApp::full().with_token();
8+
let (_app, _anon, _cookie, token) = TestApp::full().with_token().await;
99

1010
let response = token.publish_crate(PublishBuilder::new("foo", v1)).await;
1111
assert_eq!(response.status(), StatusCode::OK);

src/tests/krate/publish/categories.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use insta::{assert_json_snapshot, assert_snapshot};
1010

1111
#[tokio::test(flavor = "multi_thread")]
1212
async fn good_categories() {
13-
let (app, _, _, token) = TestApp::full().with_token();
13+
let (app, _, _, token) = TestApp::full().with_token().await;
1414
let mut conn = app.async_db_conn().await;
1515

1616
insert_into(categories::table)
@@ -30,7 +30,7 @@ async fn good_categories() {
3030

3131
#[tokio::test(flavor = "multi_thread")]
3232
async fn ignored_categories() {
33-
let (_, _, _, token) = TestApp::full().with_token();
33+
let (_, _, _, token) = TestApp::full().with_token().await;
3434

3535
let crate_to_publish = PublishBuilder::new("foo_ignored_cat", "1.0.0").category("bar");
3636
let response = token.publish_crate(crate_to_publish).await;
@@ -40,7 +40,7 @@ async fn ignored_categories() {
4040

4141
#[tokio::test(flavor = "multi_thread")]
4242
async fn too_many_categories() {
43-
let (app, _, _, token) = TestApp::full().with_token();
43+
let (app, _, _, token) = TestApp::full().with_token().await;
4444

4545
let response = token
4646
.publish_crate(

src/tests/krate/publish/deleted_crates.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use insta::assert_snapshot;
1010

1111
#[tokio::test(flavor = "multi_thread")]
1212
async fn test_recently_deleted_crate_with_same_name() -> anyhow::Result<()> {
13-
let (app, _, _, token) = TestApp::full().with_token();
13+
let (app, _, _, token) = TestApp::full().with_token().await;
1414
let mut conn = app.async_db_conn().await;
1515

1616
let now = Utc::now();

0 commit comments

Comments
 (0)