Skip to content

Commit e777d4b

Browse files
committed
assert that json exists for all targets
1 parent 679d9d6 commit e777d4b

File tree

3 files changed

+24
-46
lines changed

3 files changed

+24
-46
lines changed

src/db/delete.rs

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,17 @@ mod tests {
406406
.collect())
407407
}
408408

409+
async fn json_exists(storage: &AsyncStorage, version: &str) -> Result<bool> {
410+
storage
411+
.exists(&rustdoc_json_path(
412+
"a",
413+
version,
414+
"x86_64-unknown-linux-gnu",
415+
crate::storage::RustdocJsonFormatVersion::Latest,
416+
))
417+
.await
418+
}
419+
409420
let mut conn = env.async_db().await.async_conn().await;
410421
let v1 = env
411422
.fake_release()
@@ -427,17 +438,7 @@ mod tests {
427438
.rustdoc_file_exists("a", "1.0.0", None, "a/index.html", archive_storage)
428439
.await?
429440
);
430-
assert!(
431-
env.async_storage()
432-
.await
433-
.exists(&rustdoc_json_path(
434-
"a",
435-
"1.0.0",
436-
"x86_64-unknown-linux-gnu",
437-
crate::storage::RustdocJsonFormatVersion::Latest
438-
))
439-
.await?
440-
);
441+
assert!(json_exists(&*env.async_storage().await, "1.0.0").await?);
441442
let crate_id = sqlx::query_scalar!(
442443
r#"SELECT crate_id as "crate_id: CrateId" FROM releases WHERE id = $1"#,
443444
v1.0
@@ -469,17 +470,7 @@ mod tests {
469470
.rustdoc_file_exists("a", "2.0.0", None, "a/index.html", archive_storage)
470471
.await?
471472
);
472-
assert!(
473-
env.async_storage()
474-
.await
475-
.exists(&rustdoc_json_path(
476-
"a",
477-
"2.0.0",
478-
"x86_64-unknown-linux-gnu",
479-
crate::storage::RustdocJsonFormatVersion::Latest
480-
))
481-
.await?
482-
);
473+
assert!(json_exists(&*env.async_storage().await, "2.0.0").await?);
483474
assert_eq!(
484475
owners(&mut conn, crate_id).await?,
485476
vec!["Peter Rabbit".to_string()]
@@ -517,17 +508,7 @@ mod tests {
517508
.await?
518509
);
519510
}
520-
assert!(
521-
!env.async_storage()
522-
.await
523-
.exists(&rustdoc_json_path(
524-
"a",
525-
"1.0.0",
526-
"x86_64-unknown-linux-gnu",
527-
crate::storage::RustdocJsonFormatVersion::Latest
528-
))
529-
.await?
530-
);
511+
assert!(!json_exists(&*env.async_storage().await, "1.0.0").await?);
531512

532513
assert!(release_exists(&mut conn, v2).await?);
533514
assert!(
@@ -536,17 +517,7 @@ mod tests {
536517
.rustdoc_file_exists("a", "2.0.0", None, "a/index.html", archive_storage)
537518
.await?
538519
);
539-
assert!(
540-
env.async_storage()
541-
.await
542-
.exists(&rustdoc_json_path(
543-
"a",
544-
"2.0.0",
545-
"x86_64-unknown-linux-gnu",
546-
crate::storage::RustdocJsonFormatVersion::Latest
547-
))
548-
.await?
549-
);
520+
assert!(json_exists(&*env.async_storage().await, "2.0.0").await?);
550521
assert_eq!(
551522
owners(&mut conn, crate_id).await?,
552523
vec!["Peter Rabbit".to_string()]

src/docbuilder/rustwide_builder.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use crate::{AsyncStorage, Config, Context, InstanceMetrics, RegistryApi, Storage
2424
use crate::{db::blacklist::is_blacklisted, utils::MetadataPackage};
2525
use anyhow::{Context as _, Error, anyhow, bail};
2626
use docsrs_metadata::{BuildTargets, DEFAULT_TARGETS, HOST_TARGET, Metadata};
27-
use itertools::Itertools;
2827
use once_cell::sync::Lazy;
2928
use regex::Regex;
3029
use rustwide::cmd::{Command, CommandError, SandboxBuilder, SandboxImage};
@@ -1425,6 +1424,14 @@ mod tests {
14251424

14261425
// other targets too
14271426
for target in DEFAULT_TARGETS {
1427+
// check if rustdoc json files exist for all targets
1428+
assert!(storage.exists(&rustdoc_json_path(
1429+
crate_,
1430+
version,
1431+
target,
1432+
RustdocJsonFormatVersion::Latest
1433+
))?);
1434+
14281435
if target == &default_target {
14291436
continue;
14301437
}

src/test/fakes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ impl<'a> FakeRelease<'a> {
530530
&rustdoc_json_path(
531531
&package.name,
532532
&package.version,
533-
&target,
533+
target,
534534
format_version,
535535
),
536536
serde_json::to_vec(&serde_json::json!({

0 commit comments

Comments
 (0)