@@ -871,6 +871,90 @@ fn yank_not_owner() {
871
871
:: json :: < :: Bad > ( & mut response) ;
872
872
}
873
873
874
+ #[ test]
875
+ fn yank_max_version ( ) {
876
+ #[ derive( RustcDecodable ) ] struct O { ok : bool }
877
+ let ( _b, app, middle) = :: app ( ) ;
878
+
879
+ // Upload a new crate
880
+ let mut req = :: new_req ( app, "fyk_max" , "1.0.0" ) ;
881
+ :: mock_user ( & mut req, :: user ( "foo" ) ) ;
882
+ let mut response = ok_resp ! ( middle. call( & mut req) ) ;
883
+
884
+ // double check the max version
885
+ let json: GoodCrate = :: json ( & mut response) ;
886
+ assert ! ( json. krate. max_version. is_some( ) ) ;
887
+ assert_eq ! ( json. krate. max_version. unwrap( ) , "1.0.0" ) ;
888
+
889
+ // add version 2.0.0
890
+ let body = :: new_req_body_version_2 ( :: krate ( "fyk_max" ) ) ;
891
+ let mut response = ok_resp ! ( middle. call( req. with_path( "/api/v1/crates/new" )
892
+ . with_method( Method :: Put )
893
+ . with_body( & body) ) ) ;
894
+ let json: GoodCrate = :: json ( & mut response) ;
895
+ assert ! ( json. krate. max_version. is_some( ) ) ;
896
+ assert_eq ! ( json. krate. max_version. unwrap( ) , "2.0.0" ) ;
897
+
898
+ // yank version 1.0.0
899
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Delete )
900
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/yank" ) ) ) ;
901
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
902
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
903
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
904
+ let json: CrateResponse = :: json ( & mut response) ;
905
+ assert ! ( json. krate. max_version. is_some( ) ) ;
906
+ assert_eq ! ( json. krate. max_version. unwrap( ) , "2.0.0" ) ;
907
+
908
+ // unyank version 1.0.0
909
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Put )
910
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/unyank" ) ) ) ;
911
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
912
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
913
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
914
+ let json: CrateResponse = :: json ( & mut response) ;
915
+ assert ! ( json. krate. max_version. is_some( ) ) ;
916
+ assert_eq ! ( json. krate. max_version. unwrap( ) , "2.0.0" ) ;
917
+
918
+ // yank version 2.0.0
919
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Delete )
920
+ . with_path( "/api/v1/crates/fyk_max/2.0.0/yank" ) ) ) ;
921
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
922
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
923
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
924
+ let json: CrateResponse = :: json ( & mut response) ;
925
+ assert ! ( json. krate. max_version. is_some( ) ) ;
926
+ assert_eq ! ( json. krate. max_version. unwrap( ) , "1.0.0" ) ;
927
+
928
+ // yank version 1.0.0
929
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Delete )
930
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/yank" ) ) ) ;
931
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
932
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
933
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
934
+ let json: CrateResponse = :: json ( & mut response) ;
935
+ assert ! ( json. krate. max_version. is_none( ) ) ;
936
+
937
+ // unyank version 2.0.0
938
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Put )
939
+ . with_path( "/api/v1/crates/fyk_max/2.0.0/unyank" ) ) ) ;
940
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
941
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
942
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
943
+ let json: CrateResponse = :: json ( & mut response) ;
944
+ assert ! ( json. krate. max_version. is_some( ) ) ;
945
+ assert_eq ! ( json. krate. max_version. unwrap( ) , "2.0.0" ) ;
946
+
947
+ // unyank version 1.0.0
948
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Put )
949
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/unyank" ) ) ) ;
950
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
951
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
952
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
953
+ let json: CrateResponse = :: json ( & mut response) ;
954
+ assert ! ( json. krate. max_version. is_some( ) ) ;
955
+ assert_eq ! ( json. krate. max_version. unwrap( ) , "2.0.0" ) ;
956
+ }
957
+
874
958
#[ test]
875
959
fn bad_keywords ( ) {
876
960
let ( _b, app, middle) = :: app ( ) ;
0 commit comments