@@ -645,10 +645,11 @@ fn upgrade() {
645
645
}
646
646
647
647
#[ test]
648
- fn force_update ( ) {
649
- // On day 1 install the ' bonus' component, on day 2 its no longer a component
648
+ fn unavailable_component ( ) {
649
+ // On day 2 the bonus component is no longer available
650
650
let edit = & |date : & str , pkgs : & mut [ MockPackage ] | {
651
- if date == "2016-02-01" {
651
+ // Require the bonus component every dat
652
+ {
652
653
let tpkg = pkgs[ 0 ] . targets
653
654
. iter_mut ( )
654
655
. find ( |p| p. target == "x86_64-apple-darwin" )
@@ -658,6 +659,17 @@ fn force_update() {
658
659
target : "x86_64-apple-darwin" . to_string ( ) ,
659
660
} ) ;
660
661
}
662
+
663
+ // Mark the bonus package as unavailable in 2016-02-02
664
+ if date == "2016-02-02" {
665
+ let bonus_pkg = pkgs. iter_mut ( )
666
+ . find ( |p| p. name == "bonus" )
667
+ . unwrap ( ) ;
668
+
669
+ for target in & mut bonus_pkg. targets {
670
+ target. available = false ;
671
+ }
672
+ }
661
673
} ;
662
674
663
675
setup (
@@ -677,18 +689,54 @@ fn force_update() {
677
689
ErrorKind :: RequestedComponentsUnavailable ( ..) => { }
678
690
_ => panic ! ( ) ,
679
691
}
680
- // Force update without bonus, should succeed, but bonus binary will be missing.
681
- update_from_dist_ (
682
- url,
683
- toolchain,
684
- prefix,
685
- & [ ] ,
686
- & [ ] ,
687
- download_cfg,
688
- temp_cfg,
689
- true ,
690
- ) . unwrap ( ) ;
692
+ } ,
693
+ ) ;
694
+ }
695
+
696
+ #[ test]
697
+ fn removed_component ( ) {
698
+ // On day 1 install the 'bonus' component, on day 2 its no longer a component
699
+ let edit = & |date : & str , pkgs : & mut [ MockPackage ] | {
700
+ if date == "2016-02-01" {
701
+ let tpkg = pkgs[ 0 ] . targets
702
+ . iter_mut ( )
703
+ . find ( |p| p. target == "x86_64-apple-darwin" )
704
+ . unwrap ( ) ;
705
+ tpkg. components . push ( MockComponent {
706
+ name : "bonus" . to_string ( ) ,
707
+ target : "x86_64-apple-darwin" . to_string ( ) ,
708
+ } ) ;
709
+ }
710
+ } ;
711
+
712
+ setup (
713
+ Some ( edit) ,
714
+ false ,
715
+ & |url, toolchain, prefix, download_cfg, temp_cfg| {
716
+ let received_notification = Arc :: new ( Cell :: new ( false ) ) ;
717
+
718
+ let download_cfg = DownloadCfg {
719
+ dist_root : download_cfg. dist_root ,
720
+ temp_cfg : download_cfg. temp_cfg ,
721
+ download_dir : download_cfg. download_dir ,
722
+ notify_handler : & |n| {
723
+ if let Notification :: ComponentUnavailable ( "bonus" , Some ( _) ) = n {
724
+ received_notification. set ( true ) ;
725
+ }
726
+ } ,
727
+ } ;
728
+
729
+ change_channel_date ( url, "nightly" , "2016-02-01" ) ;
730
+ // Update with bonus.
731
+ update_from_dist ( url, toolchain, prefix, & [ ] , & [ ] , & download_cfg, temp_cfg) . unwrap ( ) ;
732
+ assert ! ( utils:: path_exists( & prefix. path( ) . join( "bin/bonus" ) ) ) ;
733
+ change_channel_date ( url, "nightly" , "2016-02-02" ) ;
734
+
735
+ // Update without bonus, should emit a notify and remove the bonus component
736
+ update_from_dist ( url, toolchain, prefix, & [ ] , & [ ] , & download_cfg, temp_cfg) . unwrap ( ) ;
691
737
assert ! ( !utils:: path_exists( & prefix. path( ) . join( "bin/bonus" ) ) ) ;
738
+
739
+ assert ! ( received_notification. get( ) ) ;
692
740
} ,
693
741
) ;
694
742
}
0 commit comments