Skip to content

Commit 269b522

Browse files
committed
migrate most tests to async, drop old testserver & blocking reqwests
1 parent ca5e707 commit 269b522

20 files changed

+2652
-2106
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ http-body-util = "0.1.0"
118118
rand = "0.8"
119119
mockito = "1.0.2"
120120
test-case = "3.0.0"
121-
reqwest = { version = "0.12", features = ["blocking", "json"] }
122121
tower = { version = "0.5.1", features = ["util"] }
123122
aws-smithy-types = "1.0.1"
124123
aws-smithy-runtime = {version = "1.0.1", features = ["client", "test-util"]}

src/build_queue.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,6 @@ impl BuildQueue {
472472
pub(crate) fn queued_crates(&self) -> Result<Vec<QueuedCrate>> {
473473
self.runtime.block_on(self.inner.queued_crates())
474474
}
475-
#[cfg(test)]
476-
pub(crate) fn has_build_queued(&self, name: &str, version: &str) -> Result<bool> {
477-
self.runtime
478-
.block_on(self.inner.has_build_queued(name, version))
479-
}
480475
}
481476

482477
impl BuildQueue {

src/docbuilder/rustwide_builder.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,10 +1019,8 @@ impl Default for BuildPackageSummary {
10191019
#[cfg(test)]
10201020
mod tests {
10211021
use super::*;
1022-
use crate::{
1023-
db::types::Feature,
1024-
test::{assert_redirect, assert_success, wrapper, TestEnvironment},
1025-
};
1022+
use crate::db::types::Feature;
1023+
use crate::test::{wrapper, AxumRouterTestExt, TestEnvironment};
10261024

10271025
fn get_features(
10281026
env: &TestEnvironment,
@@ -1149,7 +1147,8 @@ mod tests {
11491147
.collect();
11501148
targets.sort();
11511149

1152-
let web = env.frontend();
1150+
let runtime = env.runtime();
1151+
let web = runtime.block_on(env.web_app());
11531152

11541153
// old rustdoc & source files are gone
11551154
assert!(!storage.exists(&old_rustdoc_file)?);
@@ -1169,12 +1168,13 @@ mod tests {
11691168
None,
11701169
&format!("{crate_path}/index.html"),
11711170
)?);
1172-
assert_success(&format!("/{crate_}/{version}/{crate_path}"), web)?;
1171+
runtime.block_on(web.assert_success(&format!("/{crate_}/{version}/{crate_path}/")))?;
11731172

11741173
// source is also packaged
11751174
assert!(storage.exists_in_archive(&source_archive, None, "src/lib.rs",)?);
1176-
assert_success(&format!("/crate/{crate_}/{version}/source/src/lib.rs"), web)?;
1177-
1175+
runtime.block_on(
1176+
web.assert_success(&format!("/crate/{crate_}/{version}/source/src/lib.rs")),
1177+
)?;
11781178
assert!(!storage.exists_in_archive(
11791179
&doc_archive,
11801180
None,
@@ -1183,11 +1183,10 @@ mod tests {
11831183

11841184
let default_target_url =
11851185
format!("/{crate_}/{version}/{default_target}/{crate_path}/index.html");
1186-
assert_redirect(
1186+
runtime.block_on(web.assert_redirect(
11871187
&default_target_url,
11881188
&format!("/{crate_}/{version}/{crate_path}/index.html"),
1189-
web,
1190-
)?;
1189+
))?;
11911190

11921191
// Non-dist toolchains only have a single target, and of course
11931192
// if include_default_targets is false we won't have this full list
@@ -1219,7 +1218,7 @@ mod tests {
12191218
format!("/{crate_}/{version}/{target}/{crate_path}/index.html");
12201219

12211220
assert!(target_docs_present);
1222-
assert_success(&target_url, web)?;
1221+
runtime.block_on(web.assert_success(&target_url))?;
12231222

12241223
assert!(storage
12251224
.exists(&format!("build-logs/{}/{target}.txt", row.build_id))
@@ -1355,12 +1354,14 @@ mod tests {
13551354
None,
13561355
&format!("{target}/{crate_path}/index.html"),
13571356
)?;
1357+
assert!(target_docs_present);
13581358

1359-
let web = env.frontend();
1360-
let target_url = format!("/{crate_}/{version}/{target}/{crate_path}/index.html");
1359+
env.runtime().block_on(async {
1360+
let web = env.web_app().await;
1361+
let target_url = format!("/{crate_}/{version}/{target}/{crate_path}/index.html");
13611362

1362-
assert!(target_docs_present);
1363-
assert_success(&target_url, web)?;
1363+
web.assert_success(&target_url).await
1364+
})?;
13641365

13651366
Ok(())
13661367
});

0 commit comments

Comments
 (0)