@@ -1183,6 +1183,50 @@ fn reverse_dependencies() {
11831183 assert_eq ! ( deps. meta. total, 0 ) ;
11841184}
11851185
1186+ #[ test]
1187+ fn reverse_dependencies_when_old_version_doesnt_depend_but_new_does ( ) {
1188+ let ( _b, app, middle) = :: app ( ) ;
1189+
1190+ let v100 = semver:: Version :: parse ( "1.0.0" ) . unwrap ( ) ;
1191+ let v110 = semver:: Version :: parse ( "1.1.0" ) . unwrap ( ) ;
1192+ let v200 = semver:: Version :: parse ( "2.0.0" ) . unwrap ( ) ;
1193+ let mut req = :: req ( app, Method :: Get ,
1194+ "/api/v1/crates/c1/reverse_dependencies" ) ;
1195+ :: mock_user ( & mut req, :: user ( "foo" ) ) ;
1196+ let ( c1, _) = :: mock_crate_vers ( & mut req, :: krate ( "c1" ) , & v110) ;
1197+ let _ = :: mock_crate_vers ( & mut req, :: krate ( "c2" ) , & v100) ;
1198+ let ( _, c2v2) = :: mock_crate_vers ( & mut req, :: krate ( "c2" ) , & v200) ;
1199+
1200+ :: mock_dep ( & mut req, & c2v2, & c1, None ) ;
1201+
1202+ let mut response = ok_resp ! ( middle. call( & mut req) ) ;
1203+ let deps = :: json :: < RevDeps > ( & mut response) ;
1204+ assert_eq ! ( deps. dependencies. len( ) , 1 ) ;
1205+ assert_eq ! ( deps. meta. total, 1 ) ;
1206+ assert_eq ! ( deps. dependencies[ 0 ] . crate_id, "c2" ) ;
1207+ }
1208+
1209+ #[ test]
1210+ fn reverse_dependencies_when_old_version_depended_but_new_doesnt ( ) {
1211+ let ( _b, app, middle) = :: app ( ) ;
1212+
1213+ let v100 = semver:: Version :: parse ( "1.0.0" ) . unwrap ( ) ;
1214+ let v200 = semver:: Version :: parse ( "2.0.0" ) . unwrap ( ) ;
1215+ let mut req = :: req ( app, Method :: Get ,
1216+ "/api/v1/crates/c1/reverse_dependencies" ) ;
1217+ :: mock_user ( & mut req, :: user ( "foo" ) ) ;
1218+ let ( c1, _) = :: mock_crate_vers ( & mut req, :: krate ( "c1" ) , & v100) ;
1219+ let ( _, c2v1) = :: mock_crate_vers ( & mut req, :: krate ( "c2" ) , & v100) ;
1220+ let _ = :: mock_crate_vers ( & mut req, :: krate ( "c2" ) , & v200) ;
1221+
1222+ :: mock_dep ( & mut req, & c2v1, & c1, None ) ;
1223+
1224+ let mut response = ok_resp ! ( middle. call( & mut req) ) ;
1225+ let deps = :: json :: < RevDeps > ( & mut response) ;
1226+ assert_eq ! ( deps. dependencies. len( ) , 0 ) ;
1227+ assert_eq ! ( deps. meta. total, 0 ) ;
1228+ }
1229+
11861230#[ test]
11871231fn author_license_and_description_required ( ) {
11881232 let ( _b, app, middle) = :: app ( ) ;
0 commit comments