34
34
new_crate_to_body_with_tarball, new_dependency, new_req, new_req_body_version_2, new_req_full,
35
35
new_req_with_badges, new_req_with_categories, new_req_with_documentation,
36
36
new_req_with_keywords, new_user, new_version, req, sign_in, sign_in_as, Bad , CrateBuilder ,
37
- CrateMeta , CrateResponse , GoodCrate , OkBool , PublishBuilder , RequestHelper , TestApp ,
37
+ CrateList , CrateMeta , CrateResponse , GoodCrate , OkBool , PublishBuilder , RequestHelper , TestApp ,
38
38
VersionBuilder ,
39
39
} ;
40
40
@@ -79,8 +79,9 @@ impl ::util::MockTokenUser {
79
79
80
80
#[ test]
81
81
fn index ( ) {
82
- let ( app, anon) = TestApp :: empty ( ) ;
83
- let json = anon. search ( "" ) ;
82
+ let url = "/api/v1/crates" ;
83
+ let ( app, anon) = TestApp :: init ( ) . empty ( ) ;
84
+ let json: CrateList = anon. get ( url) . good ( ) ;
84
85
assert_eq ! ( json. crates. len( ) , 0 ) ;
85
86
assert_eq ! ( json. meta. total, 0 ) ;
86
87
@@ -98,7 +99,7 @@ fn index() {
98
99
99
100
#[ test]
100
101
fn index_queries ( ) {
101
- let ( app, anon, user) = TestApp :: with_user ( ) ;
102
+ let ( app, anon, user) = TestApp :: init ( ) . with_user ( ) ;
102
103
let user = user. as_model ( ) ;
103
104
104
105
let ( krate, krate2) = app. db ( |conn| {
@@ -179,7 +180,7 @@ fn index_queries() {
179
180
180
181
#[ test]
181
182
fn search_includes_crates_where_name_is_stopword ( ) {
182
- let ( app, anon, user) = TestApp :: with_user ( ) ;
183
+ let ( app, anon, user) = TestApp :: init ( ) . with_user ( ) ;
183
184
let user = user. as_model ( ) ;
184
185
app. db ( |conn| {
185
186
CrateBuilder :: new ( "which" , user. id ) . expect_build ( conn) ;
@@ -194,7 +195,7 @@ fn search_includes_crates_where_name_is_stopword() {
194
195
195
196
#[ test]
196
197
fn exact_match_first_on_queries ( ) {
197
- let ( app, anon, user) = TestApp :: with_user ( ) ;
198
+ let ( app, anon, user) = TestApp :: init ( ) . with_user ( ) ;
198
199
let user = user. as_model ( ) ;
199
200
200
201
app. db ( |conn| {
@@ -236,7 +237,7 @@ fn exact_match_first_on_queries() {
236
237
237
238
#[ test]
238
239
fn index_sorting ( ) {
239
- let ( app, anon, user) = TestApp :: with_user ( ) ;
240
+ let ( app, anon, user) = TestApp :: init ( ) . with_user ( ) ;
240
241
let user = user. as_model ( ) ;
241
242
242
243
app. db ( |conn| {
@@ -318,7 +319,7 @@ fn index_sorting() {
318
319
319
320
#[ test]
320
321
fn exact_match_on_queries_with_sort ( ) {
321
- let ( app, anon, user) = TestApp :: with_user ( ) ;
322
+ let ( app, anon, user) = TestApp :: init ( ) . with_user ( ) ;
322
323
let user = user. as_model ( ) ;
323
324
324
325
app. db ( |conn| {
@@ -416,7 +417,7 @@ fn exact_match_on_queries_with_sort() {
416
417
417
418
#[ test]
418
419
fn show ( ) {
419
- let ( app, anon, user) = TestApp :: with_user ( ) ;
420
+ let ( app, anon, user) = TestApp :: init ( ) . with_user ( ) ;
420
421
let user = user. as_model ( ) ;
421
422
422
423
let krate = app. db ( |conn| {
@@ -463,7 +464,7 @@ fn show() {
463
464
464
465
#[ test]
465
466
fn yanked_versions_are_not_considered_for_max_version ( ) {
466
- let ( app, anon, user) = TestApp :: with_user ( ) ;
467
+ let ( app, anon, user) = TestApp :: init ( ) . with_user ( ) ;
467
468
let user = user. as_model ( ) ;
468
469
469
470
app. db ( |conn| {
@@ -481,7 +482,7 @@ fn yanked_versions_are_not_considered_for_max_version() {
481
482
482
483
#[ test]
483
484
fn versions ( ) {
484
- let ( app, anon) = TestApp :: empty ( ) ;
485
+ let ( app, anon) = TestApp :: init ( ) . empty ( ) ;
485
486
app. db ( |conn| {
486
487
let u = new_user ( "foo" ) . create_or_update ( conn) . unwrap ( ) ;
487
488
CrateBuilder :: new ( "foo_versions" , u. id )
@@ -854,7 +855,7 @@ fn valid_feature_names() {
854
855
855
856
#[ test]
856
857
fn new_krate_too_big ( ) {
857
- let ( _, _, user) = TestApp :: with_user ( ) ;
858
+ let ( _, _, user) = TestApp :: init ( ) . with_user ( ) ;
858
859
let files = [ ( "foo_big-1.0.0/big" , & [ b'a' ; 2000 ] as & [ _ ] ) ] ;
859
860
let builder = PublishBuilder :: new ( "foo_big" ) . files ( & files) ;
860
861
@@ -1103,13 +1104,13 @@ fn new_krate_with_readme() {
1103
1104
1104
1105
#[ test]
1105
1106
fn summary_doesnt_die ( ) {
1106
- let ( _, anon) = TestApp :: empty ( ) ;
1107
+ let ( _, anon) = TestApp :: init ( ) . empty ( ) ;
1107
1108
anon. get :: < SummaryResponse > ( "/api/v1/summary" ) . good ( ) ;
1108
1109
}
1109
1110
1110
1111
#[ test]
1111
1112
fn summary_new_crates ( ) {
1112
- let ( app, anon, user) = TestApp :: with_user ( ) ;
1113
+ let ( app, anon, user) = TestApp :: init ( ) . with_user ( ) ;
1113
1114
let user = user. as_model ( ) ;
1114
1115
app. db ( |conn| {
1115
1116
let krate = CrateBuilder :: new ( "some_downloads" , user. id )
@@ -1176,7 +1177,7 @@ fn summary_new_crates() {
1176
1177
#[ test]
1177
1178
fn download ( ) {
1178
1179
use chrono:: { Duration , Utc } ;
1179
- let ( app, anon, user) = TestApp :: with_user ( ) ;
1180
+ let ( app, anon, user) = TestApp :: with_proxy ( ) . with_user ( ) ;
1180
1181
let user = user. as_model ( ) ;
1181
1182
1182
1183
app. db ( |conn| {
@@ -1260,7 +1261,7 @@ fn dependencies() {
1260
1261
1261
1262
#[ test]
1262
1263
fn diesel_not_found_results_in_404 ( ) {
1263
- let ( _, _, user) = TestApp :: with_user ( ) ;
1264
+ let ( _, _, user) = TestApp :: init ( ) . with_user ( ) ;
1264
1265
1265
1266
user. get ( "/api/v1/crates/foo_following/following" )
1266
1267
. assert_not_found ( ) ;
@@ -1269,7 +1270,7 @@ fn diesel_not_found_results_in_404() {
1269
1270
#[ test]
1270
1271
fn following ( ) {
1271
1272
// TODO: Test anon requests as well?
1272
- let ( app, _, user) = TestApp :: with_user ( ) ;
1273
+ let ( app, _, user) = TestApp :: init ( ) . with_user ( ) ;
1273
1274
1274
1275
app. db ( |conn| {
1275
1276
CrateBuilder :: new ( "foo_following" , user. as_model ( ) . id ) . expect_build ( & conn) ;
@@ -1399,7 +1400,7 @@ fn yank() {
1399
1400
1400
1401
#[ test]
1401
1402
fn yank_not_owner ( ) {
1402
- let ( app, _, _, token) = TestApp :: with_token ( ) ;
1403
+ let ( app, _, _, token) = TestApp :: init ( ) . with_token ( ) ;
1403
1404
app. db ( |conn| {
1404
1405
let another_user = new_user ( "bar" ) . create_or_update ( conn) . unwrap ( ) ;
1405
1406
CrateBuilder :: new ( "foo_not" , another_user. id ) . expect_build ( conn) ;
@@ -2019,7 +2020,7 @@ fn author_license_and_description_required() {
2019
2020
*/
2020
2021
#[ test]
2021
2022
fn test_recent_download_count ( ) {
2022
- let ( app, anon, user) = TestApp :: with_user ( ) ;
2023
+ let ( app, anon, user) = TestApp :: init ( ) . with_user ( ) ;
2023
2024
let user = user. as_model ( ) ;
2024
2025
2025
2026
app. db ( |conn| {
@@ -2057,7 +2058,7 @@ fn test_recent_download_count() {
2057
2058
*/
2058
2059
#[ test]
2059
2060
fn test_zero_downloads ( ) {
2060
- let ( app, anon, user) = TestApp :: with_user ( ) ;
2061
+ let ( app, anon, user) = TestApp :: init ( ) . with_user ( ) ;
2061
2062
let user = user. as_model ( ) ;
2062
2063
2063
2064
app. db ( |conn| {
@@ -2082,7 +2083,7 @@ fn test_zero_downloads() {
2082
2083
*/
2083
2084
#[ test]
2084
2085
fn test_default_sort_recent ( ) {
2085
- let ( app, anon, user) = TestApp :: with_user ( ) ;
2086
+ let ( app, anon, user) = TestApp :: init ( ) . with_user ( ) ;
2086
2087
let user = user. as_model ( ) ;
2087
2088
2088
2089
let ( green_crate, potato_crate) = app. db ( |conn| {
@@ -2145,7 +2146,7 @@ fn test_default_sort_recent() {
2145
2146
2146
2147
#[ test]
2147
2148
fn block_bad_documentation_url ( ) {
2148
- let ( app, anon, user) = TestApp :: with_user ( ) ;
2149
+ let ( app, anon, user) = TestApp :: init ( ) . with_user ( ) ;
2149
2150
let user = user. as_model ( ) ;
2150
2151
2151
2152
app. db ( |conn| {
@@ -2163,7 +2164,7 @@ fn block_bad_documentation_url() {
2163
2164
// which call the `PUT /crates/:crate_id/owners` route
2164
2165
#[ test]
2165
2166
fn test_cargo_invite_owners ( ) {
2166
- let ( app, _, owner) = TestApp :: with_user ( ) ;
2167
+ let ( app, _, owner) = TestApp :: init ( ) . with_user ( ) ;
2167
2168
2168
2169
let new_user = app. db_new_user ( "cilantro" ) ;
2169
2170
app. db ( |conn| {
0 commit comments