Skip to content

Commit

Permalink
migrate most tests to async, drop old testserver & blocking reqwests
Browse files Browse the repository at this point in the history
  • Loading branch information
syphar committed Nov 11, 2024
1 parent ca5e707 commit cec7833
Show file tree
Hide file tree
Showing 20 changed files with 2,654 additions and 2,106 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ http-body-util = "0.1.0"
rand = "0.8"
mockito = "1.0.2"
test-case = "3.0.0"
reqwest = { version = "0.12", features = ["blocking", "json"] }
tower = { version = "0.5.1", features = ["util"] }
aws-smithy-types = "1.0.1"
aws-smithy-runtime = {version = "1.0.1", features = ["client", "test-util"]}
Expand Down
5 changes: 0 additions & 5 deletions src/build_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,6 @@ impl BuildQueue {
pub(crate) fn queued_crates(&self) -> Result<Vec<QueuedCrate>> {
self.runtime.block_on(self.inner.queued_crates())
}
#[cfg(test)]
pub(crate) fn has_build_queued(&self, name: &str, version: &str) -> Result<bool> {
self.runtime
.block_on(self.inner.has_build_queued(name, version))
}
}

impl BuildQueue {
Expand Down
33 changes: 17 additions & 16 deletions src/docbuilder/rustwide_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,10 +1019,8 @@ impl Default for BuildPackageSummary {
#[cfg(test)]
mod tests {
use super::*;
use crate::{
db::types::Feature,
test::{assert_redirect, assert_success, wrapper, TestEnvironment},
};
use crate::db::types::Feature;
use crate::test::{wrapper, AxumRouterTestExt, TestEnvironment};

fn get_features(
env: &TestEnvironment,
Expand Down Expand Up @@ -1149,7 +1147,8 @@ mod tests {
.collect();
targets.sort();

let web = env.frontend();
let runtime = env.runtime();
let web = runtime.block_on(env.web_app());

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

// source is also packaged
assert!(storage.exists_in_archive(&source_archive, None, "src/lib.rs",)?);
assert_success(&format!("/crate/{crate_}/{version}/source/src/lib.rs"), web)?;

runtime.block_on(
web.assert_success(&format!("/crate/{crate_}/{version}/source/src/lib.rs")),
)?;
assert!(!storage.exists_in_archive(
&doc_archive,
None,
Expand All @@ -1183,11 +1183,10 @@ mod tests {

let default_target_url =
format!("/{crate_}/{version}/{default_target}/{crate_path}/index.html");
assert_redirect(
runtime.block_on(web.assert_redirect(
&default_target_url,
&format!("/{crate_}/{version}/{crate_path}/index.html"),
web,
)?;
))?;

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

assert!(target_docs_present);
assert_success(&target_url, web)?;
runtime.block_on(web.assert_success(&target_url))?;

assert!(storage
.exists(&format!("build-logs/{}/{target}.txt", row.build_id))
Expand Down Expand Up @@ -1355,12 +1354,14 @@ mod tests {
None,
&format!("{target}/{crate_path}/index.html"),
)?;
assert!(target_docs_present);

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

assert!(target_docs_present);
assert_success(&target_url, web)?;
web.assert_success(&target_url).await
})?;

Ok(())
});
Expand Down
Loading

0 comments on commit cec7833

Please sign in to comment.