@@ -882,6 +882,130 @@ fn yank_not_owner() {
882
882
:: json :: < :: Bad > ( & mut response) ;
883
883
}
884
884
885
+ #[ test]
886
+ fn yank_max_version ( ) {
887
+ #[ derive( RustcDecodable ) ]
888
+ struct O {
889
+ ok : bool ,
890
+ }
891
+ let ( _b, app, middle) = :: app ( ) ;
892
+
893
+ // Upload a new crate
894
+ let mut req = :: new_req ( app, "fyk_max" , "1.0.0" ) ;
895
+ :: mock_user ( & mut req, :: user ( "foo" ) ) ;
896
+ let mut response = ok_resp ! ( middle. call( & mut req) ) ;
897
+
898
+ // double check the max version
899
+ let json: GoodCrate = :: json ( & mut response) ;
900
+ assert_eq ! ( json. krate. max_version, "1.0.0" ) ;
901
+
902
+ // add version 2.0.0
903
+ let body = :: new_req_body_version_2 ( :: krate ( "fyk_max" ) ) ;
904
+ let mut response = ok_resp ! ( middle. call( req. with_path( "/api/v1/crates/new" )
905
+ . with_method( Method :: Put )
906
+ . with_body( & body) ) ) ;
907
+ let json: GoodCrate = :: json ( & mut response) ;
908
+ assert_eq ! ( json. krate. max_version, "2.0.0" ) ;
909
+
910
+ // yank version 1.0.0
911
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Delete )
912
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/yank" ) ) ) ;
913
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
914
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
915
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
916
+ let json: CrateResponse = :: json ( & mut response) ;
917
+ assert_eq ! ( json. krate. max_version, "2.0.0" ) ;
918
+
919
+ // unyank version 1.0.0
920
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Put )
921
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/unyank" ) ) ) ;
922
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
923
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
924
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
925
+ let json: CrateResponse = :: json ( & mut response) ;
926
+ assert_eq ! ( json. krate. max_version, "2.0.0" ) ;
927
+
928
+ // yank version 2.0.0
929
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Delete )
930
+ . with_path( "/api/v1/crates/fyk_max/2.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_eq ! ( json. krate. max_version, "1.0.0" ) ;
936
+
937
+ // yank version 1.0.0
938
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Delete )
939
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/yank" ) ) ) ;
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_eq ! ( json. krate. max_version, "0.0.0" ) ;
945
+
946
+ // unyank version 2.0.0
947
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Put )
948
+ . with_path( "/api/v1/crates/fyk_max/2.0.0/unyank" ) ) ) ;
949
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
950
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
951
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
952
+ let json: CrateResponse = :: json ( & mut response) ;
953
+ assert_eq ! ( json. krate. max_version, "2.0.0" ) ;
954
+
955
+ // unyank version 1.0.0
956
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Put )
957
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/unyank" ) ) ) ;
958
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
959
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
960
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
961
+ let json: CrateResponse = :: json ( & mut response) ;
962
+ assert_eq ! ( json. krate. max_version, "2.0.0" ) ;
963
+ }
964
+
965
+ #[ test]
966
+ fn publish_after_yank_max_version ( ) {
967
+ #[ derive( RustcDecodable ) ]
968
+ struct O {
969
+ ok : bool ,
970
+ }
971
+ let ( _b, app, middle) = :: app ( ) ;
972
+
973
+ // Upload a new crate
974
+ let mut req = :: new_req ( app, "fyk_max" , "1.0.0" ) ;
975
+ :: mock_user ( & mut req, :: user ( "foo" ) ) ;
976
+ let mut response = ok_resp ! ( middle. call( & mut req) ) ;
977
+
978
+ // double check the max version
979
+ let json: GoodCrate = :: json ( & mut response) ;
980
+ assert_eq ! ( json. krate. max_version, "1.0.0" ) ;
981
+
982
+ // yank version 1.0.0
983
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Delete )
984
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/yank" ) ) ) ;
985
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
986
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
987
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
988
+ let json: CrateResponse = :: json ( & mut response) ;
989
+ assert_eq ! ( json. krate. max_version, "0.0.0" ) ;
990
+
991
+ // add version 2.0.0
992
+ let body = :: new_req_body_version_2 ( :: krate ( "fyk_max" ) ) ;
993
+ let mut response = ok_resp ! ( middle. call( req. with_path( "/api/v1/crates/new" )
994
+ . with_method( Method :: Put )
995
+ . with_body( & body) ) ) ;
996
+ let json: GoodCrate = :: json ( & mut response) ;
997
+ assert_eq ! ( json. krate. max_version, "2.0.0" ) ;
998
+
999
+ // unyank version 1.0.0
1000
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Put )
1001
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/unyank" ) ) ) ;
1002
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
1003
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
1004
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
1005
+ let json: CrateResponse = :: json ( & mut response) ;
1006
+ assert_eq ! ( json. krate. max_version, "2.0.0" ) ;
1007
+ }
1008
+
885
1009
#[ test]
886
1010
fn bad_keywords ( ) {
887
1011
let ( _b, app, middle) = :: app ( ) ;
0 commit comments