@@ -865,6 +865,130 @@ fn yank_not_owner() {
865
865
:: json :: < :: Bad > ( & mut response) ;
866
866
}
867
867
868
+ #[ test]
869
+ fn yank_max_version ( ) {
870
+ #[ derive( RustcDecodable ) ]
871
+ struct O {
872
+ ok : bool ,
873
+ }
874
+ let ( _b, app, middle) = :: app ( ) ;
875
+
876
+ // Upload a new crate
877
+ let mut req = :: new_req ( app, "fyk_max" , "1.0.0" ) ;
878
+ :: mock_user ( & mut req, :: user ( "foo" ) ) ;
879
+ let mut response = ok_resp ! ( middle. call( & mut req) ) ;
880
+
881
+ // double check the max version
882
+ let json: GoodCrate = :: json ( & mut response) ;
883
+ assert_eq ! ( json. krate. max_version, "1.0.0" ) ;
884
+
885
+ // add version 2.0.0
886
+ let body = :: new_req_body_version_2 ( :: krate ( "fyk_max" ) ) ;
887
+ let mut response = ok_resp ! ( middle. call( req. with_path( "/api/v1/crates/new" )
888
+ . with_method( Method :: Put )
889
+ . with_body( & body) ) ) ;
890
+ let json: GoodCrate = :: json ( & mut response) ;
891
+ assert_eq ! ( json. krate. max_version, "2.0.0" ) ;
892
+
893
+ // yank version 1.0.0
894
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Delete )
895
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/yank" ) ) ) ;
896
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
897
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
898
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
899
+ let json: CrateResponse = :: json ( & mut response) ;
900
+ assert_eq ! ( json. krate. max_version, "2.0.0" ) ;
901
+
902
+ // unyank version 1.0.0
903
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Put )
904
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/unyank" ) ) ) ;
905
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
906
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
907
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
908
+ let json: CrateResponse = :: json ( & mut response) ;
909
+ assert_eq ! ( json. krate. max_version, "2.0.0" ) ;
910
+
911
+ // yank version 2.0.0
912
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Delete )
913
+ . with_path( "/api/v1/crates/fyk_max/2.0.0/yank" ) ) ) ;
914
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
915
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
916
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
917
+ let json: CrateResponse = :: json ( & mut response) ;
918
+ assert_eq ! ( json. krate. max_version, "1.0.0" ) ;
919
+
920
+ // yank version 1.0.0
921
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Delete )
922
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/yank" ) ) ) ;
923
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
924
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
925
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
926
+ let json: CrateResponse = :: json ( & mut response) ;
927
+ assert_eq ! ( json. krate. max_version, "0.0.0" ) ;
928
+
929
+ // unyank version 2.0.0
930
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Put )
931
+ . with_path( "/api/v1/crates/fyk_max/2.0.0/unyank" ) ) ) ;
932
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
933
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
934
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
935
+ let json: CrateResponse = :: json ( & mut response) ;
936
+ assert_eq ! ( json. krate. max_version, "2.0.0" ) ;
937
+
938
+ // unyank version 1.0.0
939
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Put )
940
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/unyank" ) ) ) ;
941
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
942
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
943
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
944
+ let json: CrateResponse = :: json ( & mut response) ;
945
+ assert_eq ! ( json. krate. max_version, "2.0.0" ) ;
946
+ }
947
+
948
+ #[ test]
949
+ fn publish_after_yank_max_version ( ) {
950
+ #[ derive( RustcDecodable ) ]
951
+ struct O {
952
+ ok : bool ,
953
+ }
954
+ let ( _b, app, middle) = :: app ( ) ;
955
+
956
+ // Upload a new crate
957
+ let mut req = :: new_req ( app, "fyk_max" , "1.0.0" ) ;
958
+ :: mock_user ( & mut req, :: user ( "foo" ) ) ;
959
+ let mut response = ok_resp ! ( middle. call( & mut req) ) ;
960
+
961
+ // double check the max version
962
+ let json: GoodCrate = :: json ( & mut response) ;
963
+ assert_eq ! ( json. krate. max_version, "1.0.0" ) ;
964
+
965
+ // yank version 1.0.0
966
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Delete )
967
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/yank" ) ) ) ;
968
+ assert ! ( :: json:: <O >( & mut r) . ok) ;
969
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Get )
970
+ . with_path( "/api/v1/crates/fyk_max" ) ) ) ;
971
+ let json: CrateResponse = :: json ( & mut response) ;
972
+ assert_eq ! ( json. krate. max_version, "0.0.0" ) ;
973
+
974
+ // add version 2.0.0
975
+ let body = :: new_req_body_version_2 ( :: krate ( "fyk_max" ) ) ;
976
+ let mut response = ok_resp ! ( middle. call( req. with_path( "/api/v1/crates/new" )
977
+ . with_method( Method :: Put )
978
+ . with_body( & body) ) ) ;
979
+ let json: GoodCrate = :: json ( & mut response) ;
980
+ assert_eq ! ( json. krate. max_version, "2.0.0" ) ;
981
+
982
+ // unyank version 1.0.0
983
+ let mut r = ok_resp ! ( middle. call( req. with_method( Method :: Put )
984
+ . with_path( "/api/v1/crates/fyk_max/1.0.0/unyank" ) ) ) ;
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, "2.0.0" ) ;
990
+ }
991
+
868
992
#[ test]
869
993
fn bad_keywords ( ) {
870
994
let ( _b, app, middle) = :: app ( ) ;
0 commit comments