Skip to content

Commit

Permalink
try test 2
Browse files Browse the repository at this point in the history
  • Loading branch information
syphar committed Jan 10, 2025
1 parent 4ea825c commit a2083b7
Showing 1 changed file with 84 additions and 11 deletions.
95 changes: 84 additions & 11 deletions src/docbuilder/rustwide_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,8 +1041,12 @@ impl Default for BuildPackageSummary {

#[cfg(test)]
mod tests {
use std::iter;

use super::*;
use crate::db::types::Feature;
use crate::registry_api::ReleaseData;
use crate::storage::CompressionAlgorithm;
use crate::test::{wrapper, AxumRouterTestExt, TestEnvironment};

fn get_features(
Expand Down Expand Up @@ -1323,24 +1327,93 @@ mod tests {
// https://github.com/rust-lang/docs.rs/issues/26750
let crate_ = "rand";
let version = "0.8.5";

// create a successful release & build in the database
let release_id = env.runtime().block_on(async {
let mut conn = env.async_db().await.async_conn().await;
let crate_id = initialize_crate(&mut conn, &crate_).await?;
let release_id = initialize_release(&mut conn, crate_id, &version).await?;
let build_id = initialize_build(&mut conn, release_id).await?;
finish_build(
&mut conn,
build_id,
"some-version",
"other-version",
BuildStatus::Success,
None,
None,
)
.await?;
finish_release(
&mut conn,
crate_id,
release_id,
&MetadataPackage::default(),
&Path::new("/unknown/"),
"x86_64-unknown-linux-gnu",
serde_json::Value::Array(vec![]),
vec![
"i686-pc-windows-msvc".into(),
"i686-unknown-linux-gnu".into(),
"x86_64-apple-darwin".into(),
"x86_64-pc-windows-msvc".into(),
"x86_64-unknown-linux-gnu".into(),
],
&ReleaseData::default(),
true,
false,
iter::once(CompressionAlgorithm::Bzip2),
None,
true,
42,
)
.await?;

Ok::<_, anyhow::Error>(release_id)
})?;

fn check_rustdoc_status(
env: &TestEnvironment,
rid: ReleaseId,
crate_: &str,
version: &str,
) -> Result<()> {
assert_eq!(
env.runtime().block_on(async {
let mut conn = env.async_db().await.async_conn().await;
sqlx::query_scalar!(
"SELECT rustdoc_status FROM releases WHERE id = $1",
rid.0
)
.fetch_one(&mut *conn)
.await
})?,
Some(true)
);
let storage = env.storage();

// doc archive exists
let doc_archive = rustdoc_archive_path(crate_, version);
assert!(storage.exists(&doc_archive)?);

// source archive exists
let source_archive = source_archive_path(crate_, version);
assert!(storage.exists(&source_archive)?);
Ok(())
}

check_rustdoc_status(env, release_id, &crate_, &version)?;

let mut builder = RustwideBuilder::init(env).unwrap();
builder.update_toolchain()?;
assert!(
builder
// not successful build
!builder
.build_package(crate_, version, PackageKind::CratesIo)?
.successful
);

let storage = env.storage();

// doc archive exists
let doc_archive = rustdoc_archive_path(crate_, version);
assert!(storage.exists(&doc_archive)?);

// source archive exists
let source_archive = source_archive_path(crate_, version);
assert!(storage.exists(&source_archive)?);

check_rustdoc_status(env, release_id, &crate_, &version)?;
Ok(())
});
}
Expand Down

0 comments on commit a2083b7

Please sign in to comment.