2
2
3
3
use crate :: {
4
4
build_queue:: QueuedCrate ,
5
+ cdn:: { self , CrateInvalidation } ,
5
6
db:: { Pool , PoolClient } ,
6
7
impl_webpage,
7
8
utils:: report_error,
@@ -668,6 +669,7 @@ pub fn activity_handler(req: &mut Request) -> IronResult<Response> {
668
669
struct BuildQueuePage {
669
670
description : & ' static str ,
670
671
queue : Vec < QueuedCrate > ,
672
+ active_deployments : Vec < CrateInvalidation > ,
671
673
}
672
674
673
675
impl_webpage ! {
@@ -683,9 +685,12 @@ pub fn build_queue_handler(req: &mut Request) -> IronResult<Response> {
683
685
krate. priority = -krate. priority ;
684
686
}
685
687
688
+ let mut conn = extension ! ( req, Pool ) . get ( ) ?;
689
+
686
690
BuildQueuePage {
687
- description : "List of crates scheduled to build" ,
691
+ description : "crate documentation scheduled to build & deploy " ,
688
692
queue,
693
+ active_deployments : ctry ! ( req, cdn:: active_crate_invalidations( & mut conn) ) ,
689
694
}
690
695
. into_response ( req)
691
696
}
@@ -695,7 +700,8 @@ mod tests {
695
700
use super :: * ;
696
701
use crate :: index:: api:: CrateOwner ;
697
702
use crate :: test:: {
698
- assert_redirect, assert_redirect_unchecked, assert_success, wrapper, TestFrontend ,
703
+ assert_redirect, assert_redirect_unchecked, assert_success, wrapper, FakeBuild ,
704
+ TestFrontend ,
699
705
} ;
700
706
use anyhow:: Error ;
701
707
use chrono:: { Duration , TimeZone } ;
@@ -1326,6 +1332,40 @@ mod tests {
1326
1332
} )
1327
1333
}
1328
1334
1335
+ #[ test]
1336
+ fn test_deployment_queue ( ) {
1337
+ wrapper ( |env| {
1338
+ let web = env. frontend ( ) ;
1339
+
1340
+ env. fake_release ( )
1341
+ . name ( "krate_2" )
1342
+ . version ( "0.0.1" )
1343
+ . builds ( vec ! [
1344
+ FakeBuild :: default ( ) . build_time( Utc :: now( ) - Duration :: minutes( 10 ) )
1345
+ ] )
1346
+ . create ( ) ?;
1347
+
1348
+ let empty = kuchiki:: parse_html ( ) . one ( web. get ( "/releases/queue" ) . send ( ) ?. text ( ) ?) ;
1349
+ assert ! ( empty
1350
+ . select( ".release > strong" )
1351
+ . expect( "missing heading" )
1352
+ . any( |el| el. text_contents( ) . contains( "active CDN deployments" ) ) ) ;
1353
+
1354
+ let full = kuchiki:: parse_html ( ) . one ( web. get ( "/releases/queue" ) . send ( ) ?. text ( ) ?) ;
1355
+ let items = full
1356
+ . select ( ".queue-list > li" )
1357
+ . expect ( "missing list items" )
1358
+ . collect :: < Vec < _ > > ( ) ;
1359
+
1360
+ assert_eq ! ( items. len( ) , 1 ) ;
1361
+ let a = items[ 0 ] . as_node ( ) . select_first ( "a" ) . expect ( "missing link" ) ;
1362
+
1363
+ assert ! ( a. text_contents( ) . contains( "krate_2" ) ) ;
1364
+
1365
+ Ok ( ( ) )
1366
+ } ) ;
1367
+ }
1368
+
1329
1369
#[ test]
1330
1370
fn test_releases_queue ( ) {
1331
1371
wrapper ( |env| {
@@ -1334,10 +1374,15 @@ mod tests {
1334
1374
1335
1375
let empty = kuchiki:: parse_html ( ) . one ( web. get ( "/releases/queue" ) . send ( ) ?. text ( ) ?) ;
1336
1376
assert ! ( empty
1337
- . select( ".release > strong" )
1377
+ . select( ".queue-list > strong" )
1338
1378
. expect( "missing heading" )
1339
1379
. any( |el| el. text_contents( ) . contains( "nothing" ) ) ) ;
1340
1380
1381
+ assert ! ( !empty
1382
+ . select( ".release > strong" )
1383
+ . expect( "missing heading" )
1384
+ . any( |el| el. text_contents( ) . contains( "active CDN deployments" ) ) ) ;
1385
+
1341
1386
queue. add_crate ( "foo" , "1.0.0" , 0 , None ) ?;
1342
1387
queue. add_crate ( "bar" , "0.1.0" , -10 , None ) ?;
1343
1388
queue. add_crate ( "baz" , "0.0.1" , 10 , None ) ?;
0 commit comments