@@ -1041,8 +1041,12 @@ impl Default for BuildPackageSummary {
10411041
10421042#[ cfg( test) ]  
10431043mod  tests { 
1044+     use  std:: iter; 
1045+ 
10441046    use  super :: * ; 
10451047    use  crate :: db:: types:: Feature ; 
1048+     use  crate :: registry_api:: ReleaseData ; 
1049+     use  crate :: storage:: CompressionAlgorithm ; 
10461050    use  crate :: test:: { wrapper,  AxumRouterTestExt ,  TestEnvironment } ; 
10471051
10481052    fn  get_features ( 
@@ -1323,24 +1327,93 @@ mod tests {
13231327            // https://github.com/rust-lang/docs.rs/issues/26750 
13241328            let  crate_ = "rand" ; 
13251329            let  version = "0.8.5" ; 
1330+ 
1331+             // create a successful release & build in the database 
1332+             let  release_id = env. runtime ( ) . block_on ( async  { 
1333+                 let  mut  conn = env. async_db ( ) . await . async_conn ( ) . await ; 
1334+                 let  crate_id = initialize_crate ( & mut  conn,  & crate_) . await ?; 
1335+                 let  release_id = initialize_release ( & mut  conn,  crate_id,  & version) . await ?; 
1336+                 let  build_id = initialize_build ( & mut  conn,  release_id) . await ?; 
1337+                 finish_build ( 
1338+                     & mut  conn, 
1339+                     build_id, 
1340+                     "some-version" , 
1341+                     "other-version" , 
1342+                     BuildStatus :: Success , 
1343+                     None , 
1344+                     None , 
1345+                 ) 
1346+                 . await ?; 
1347+                 finish_release ( 
1348+                     & mut  conn, 
1349+                     crate_id, 
1350+                     release_id, 
1351+                     & MetadataPackage :: default ( ) , 
1352+                     & Path :: new ( "/unknown/" ) , 
1353+                     "x86_64-unknown-linux-gnu" , 
1354+                     serde_json:: Value :: Array ( vec ! [ ] ) , 
1355+                     vec ! [ 
1356+                         "i686-pc-windows-msvc" . into( ) , 
1357+                         "i686-unknown-linux-gnu" . into( ) , 
1358+                         "x86_64-apple-darwin" . into( ) , 
1359+                         "x86_64-pc-windows-msvc" . into( ) , 
1360+                         "x86_64-unknown-linux-gnu" . into( ) , 
1361+                     ] , 
1362+                     & ReleaseData :: default ( ) , 
1363+                     true , 
1364+                     false , 
1365+                     iter:: once ( CompressionAlgorithm :: Bzip2 ) , 
1366+                     None , 
1367+                     true , 
1368+                     42 , 
1369+                 ) 
1370+                 . await ?; 
1371+ 
1372+                 Ok :: < _ ,  anyhow:: Error > ( release_id) 
1373+             } ) ?; 
1374+ 
1375+             fn  check_rustdoc_status ( 
1376+                 env :  & TestEnvironment , 
1377+                 rid :  ReleaseId , 
1378+                 crate_ :  & str , 
1379+                 version :  & str , 
1380+             )  -> Result < ( ) >  { 
1381+                 assert_eq ! ( 
1382+                     env. runtime( ) . block_on( async  { 
1383+                         let  mut  conn = env. async_db( ) . await . async_conn( ) . await ; 
1384+                         sqlx:: query_scalar!( 
1385+                             "SELECT rustdoc_status FROM releases WHERE id = $1" , 
1386+                             rid. 0 
1387+                         ) 
1388+                         . fetch_one( & mut  * conn) 
1389+                         . await 
1390+                     } ) ?, 
1391+                     Some ( true ) 
1392+                 ) ; 
1393+                 let  storage = env. storage ( ) ; 
1394+ 
1395+                 // doc archive exists 
1396+                 let  doc_archive = rustdoc_archive_path ( crate_,  version) ; 
1397+                 assert ! ( storage. exists( & doc_archive) ?) ; 
1398+ 
1399+                 // source archive exists 
1400+                 let  source_archive = source_archive_path ( crate_,  version) ; 
1401+                 assert ! ( storage. exists( & source_archive) ?) ; 
1402+                 Ok ( ( ) ) 
1403+             } 
1404+ 
1405+             check_rustdoc_status ( env,  release_id,  & crate_,  & version) ?; 
1406+ 
13261407            let  mut  builder = RustwideBuilder :: init ( env) . unwrap ( ) ; 
13271408            builder. update_toolchain ( ) ?; 
13281409            assert ! ( 
1329-                 builder
1410+                 // not successful build 
1411+                 !builder
13301412                    . build_package( crate_,  version,  PackageKind :: CratesIo ) ?
13311413                    . successful
13321414            ) ; 
13331415
1334-             let  storage = env. storage ( ) ; 
1335- 
1336-             // doc archive exists 
1337-             let  doc_archive = rustdoc_archive_path ( crate_,  version) ; 
1338-             assert ! ( storage. exists( & doc_archive) ?) ; 
1339- 
1340-             // source archive exists 
1341-             let  source_archive = source_archive_path ( crate_,  version) ; 
1342-             assert ! ( storage. exists( & source_archive) ?) ; 
1343- 
1416+             check_rustdoc_status ( env,  release_id,  & crate_,  & version) ?; 
13441417            Ok ( ( ) ) 
13451418        } ) ; 
13461419    } 
0 commit comments