Skip to content

Commit 13bb603

Browse files
committed
Auto merge of #3832 - hi-rustin:rustin-patch-rename, r=Turbo87
Rename the json method of Response to into_json Signed-off-by: hi-rustin <[email protected]> r? `@jtgeibel`
2 parents 5d94e30 + 5642768 commit 13bb603

File tree

11 files changed

+70
-71
lines changed

11 files changed

+70
-71
lines changed

src/tests/account_lock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn account_locked_indefinitely() {
3434
LOCK_REASON
3535
);
3636
assert_eq!(
37-
response.json(),
37+
response.into_json(),
3838
json!({ "errors": [{ "detail": error_message }] })
3939
);
4040
}
@@ -55,7 +55,7 @@ fn account_locked_with_future_expiry() {
5555
until, LOCK_REASON,
5656
);
5757
assert_eq!(
58-
response.json(),
58+
response.into_json(),
5959
json!({ "errors": [{ "detail": error_message }] })
6060
);
6161
}

src/tests/authentication.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn anonymous_user_unauthorized() {
1515
let response: Response<Body> = anon.get(URL);
1616

1717
assert_eq!(response.status(), StatusCode::FORBIDDEN);
18-
assert_eq!(response.json().to_string().as_bytes(), MUST_LOGIN);
18+
assert_eq!(response.into_json().to_string().as_bytes(), MUST_LOGIN);
1919
}
2020

2121
#[test]
@@ -26,7 +26,7 @@ fn token_auth_cannot_find_token() {
2626
let response: Response<Body> = anon.run(request);
2727

2828
assert_eq!(response.status(), StatusCode::FORBIDDEN);
29-
assert_eq!(response.json().to_string().as_bytes(), MUST_LOGIN);
29+
assert_eq!(response.into_json().to_string().as_bytes(), MUST_LOGIN);
3030
}
3131

3232
// Ensure that an unexpected authentication error is available for logging. The user would see

src/tests/krate/dependencies.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn dependencies() {
2929
let response = anon.get::<()>("/api/v1/crates/foo_deps/1.0.2/dependencies");
3030
assert_eq!(response.status(), StatusCode::OK);
3131
assert_eq!(
32-
response.json(),
32+
response.into_json(),
3333
json!({ "errors": [{ "detail": "crate `foo_deps` does not have a version `1.0.2`" }] })
3434
);
3535
}

src/tests/krate/publish.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn new_wrong_token() {
5959
let response = anon.enqueue_publish(crate_to_publish);
6060
assert_eq!(response.status(), StatusCode::FORBIDDEN);
6161
assert_eq!(
62-
response.json(),
62+
response.into_json(),
6363
json!({ "errors": [{ "detail": "must be logged in to perform that action" }] })
6464
);
6565

@@ -75,7 +75,7 @@ fn new_wrong_token() {
7575
let response = token.enqueue_publish(crate_to_publish);
7676
assert_eq!(response.status(), StatusCode::FORBIDDEN);
7777
assert_eq!(
78-
response.json(),
78+
response.into_json(),
7979
json!({ "errors": [{ "detail": "must be logged in to perform that action" }] })
8080
);
8181
}
@@ -89,7 +89,7 @@ fn invalid_names() {
8989
let response = token.enqueue_publish(crate_to_publish);
9090
assert_eq!(response.status(), StatusCode::OK);
9191

92-
let json = response.json();
92+
let json = response.into_json();
9393
let json = json.as_object().unwrap();
9494
let errors = json.get("errors").unwrap().as_array().unwrap();
9595
let first_error = errors.first().unwrap().as_object().unwrap();
@@ -281,7 +281,7 @@ fn reject_new_krate_with_non_exact_dependency() {
281281
let response = token.enqueue_publish(crate_to_publish);
282282
assert_eq!(response.status(), StatusCode::OK);
283283
assert_eq!(
284-
response.json(),
284+
response.into_json(),
285285
json!({ "errors": [{ "detail": "no known crate named `foo_dep`" }] })
286286
);
287287
}
@@ -310,7 +310,7 @@ fn reject_new_crate_with_alternative_registry_dependency() {
310310
let response = token.enqueue_publish(crate_to_publish);
311311
assert_eq!(response.status(), StatusCode::OK);
312312
assert_eq!(
313-
response.json(),
313+
response.into_json(),
314314
json!({ "errors": [{ "detail": "Dependency `dep` is hosted on another registry. Cross-registry dependencies are not permitted on crates.io." }] })
315315
);
316316
}
@@ -333,7 +333,7 @@ fn new_krate_with_wildcard_dependency() {
333333
let response = token.enqueue_publish(crate_to_publish);
334334
assert_eq!(response.status(), StatusCode::OK);
335335
assert_eq!(
336-
response.json(),
336+
response.into_json(),
337337
json!({ "errors": [{ "detail": WILDCARD_ERROR_MESSAGE }] })
338338
);
339339
}
@@ -372,7 +372,7 @@ fn new_krate_wrong_user() {
372372
let response = another_user.enqueue_publish(crate_to_publish);
373373
assert_eq!(response.status(), StatusCode::OK);
374374
assert_eq!(
375-
response.json(),
375+
response.into_json(),
376376
json!({ "errors": [{ "detail": MISSING_RIGHTS_ERROR_MESSAGE }] })
377377
);
378378
}
@@ -387,7 +387,7 @@ fn new_krate_too_big() {
387387
let response = user.enqueue_publish(builder);
388388
assert_eq!(response.status(), StatusCode::OK);
389389
assert_eq!(
390-
response.json(),
390+
response.into_json(),
391391
json!({ "errors": [{ "detail": "uploaded tarball is malformed or too large when decompressed" }] })
392392
);
393393
}
@@ -420,7 +420,7 @@ fn new_krate_wrong_files() {
420420
let response = user.enqueue_publish(builder);
421421
assert_eq!(response.status(), StatusCode::OK);
422422
assert_eq!(
423-
response.json(),
423+
response.into_json(),
424424
json!({ "errors": [{ "detail": "invalid tarball uploaded" }] })
425425
);
426426
}
@@ -439,7 +439,7 @@ fn new_krate_gzip_bomb() {
439439
let response = token.enqueue_publish(crate_to_publish);
440440
assert_eq!(response.status(), StatusCode::OK);
441441
assert_eq!(
442-
response.json(),
442+
response.into_json(),
443443
json!({ "errors": [{ "detail": "uploaded tarball is malformed or too large when decompressed" }] })
444444
);
445445
}
@@ -459,7 +459,7 @@ fn new_krate_duplicate_version() {
459459
let response = token.enqueue_publish(crate_to_publish);
460460
assert_eq!(response.status(), StatusCode::OK);
461461
assert_eq!(
462-
response.json(),
462+
response.into_json(),
463463
json!({ "errors": [{ "detail": "crate version `1.0.0` is already uploaded" }] })
464464
);
465465
}
@@ -478,7 +478,7 @@ fn new_crate_similar_name() {
478478
let response = token.enqueue_publish(crate_to_publish);
479479
assert_eq!(response.status(), StatusCode::OK);
480480
assert_eq!(
481-
response.json(),
481+
response.into_json(),
482482
json!({ "errors": [{ "detail": "crate was previously named `Foo_similar`" }] })
483483
);
484484
}
@@ -497,7 +497,7 @@ fn new_crate_similar_name_hyphen() {
497497
let response = token.enqueue_publish(crate_to_publish);
498498
assert_eq!(response.status(), StatusCode::OK);
499499
assert_eq!(
500-
response.json(),
500+
response.into_json(),
501501
json!({ "errors": [{ "detail": "crate was previously named `foo_bar_hyphen`" }] })
502502
);
503503
}
@@ -516,7 +516,7 @@ fn new_crate_similar_name_underscore() {
516516
let response = token.enqueue_publish(crate_to_publish);
517517
assert_eq!(response.status(), StatusCode::OK);
518518
assert_eq!(
519-
response.json(),
519+
response.into_json(),
520520
json!({ "errors": [{ "detail": "crate was previously named `foo-bar-underscore`" }] })
521521
);
522522
}
@@ -589,7 +589,7 @@ fn new_krate_dependency_missing() {
589589
let response = token.enqueue_publish(crate_to_publish);
590590
assert_eq!(response.status(), StatusCode::OK);
591591
assert_eq!(
592-
response.json(),
592+
response.into_json(),
593593
json!({ "errors": [{ "detail": "no known crate named `bar_missing`" }] })
594594
);
595595
}
@@ -618,7 +618,7 @@ fn new_krate_without_any_email_fails() {
618618
let response = token.enqueue_publish(crate_to_publish);
619619
assert_eq!(response.status(), StatusCode::OK);
620620
assert_eq!(
621-
response.json(),
621+
response.into_json(),
622622
json!({ "errors": [{ "detail": "A verified email address is required to publish crates to crates.io. Visit https://crates.io/me to set and verify your email address." }] })
623623
);
624624
}
@@ -639,7 +639,7 @@ fn new_krate_with_unverified_email_fails() {
639639
let response = token.enqueue_publish(crate_to_publish);
640640
assert_eq!(response.status(), StatusCode::OK);
641641
assert_eq!(
642-
response.json(),
642+
response.into_json(),
643643
json!({ "errors": [{ "detail": "A verified email address is required to publish crates to crates.io. Visit https://crates.io/me to set and verify your email address." }] })
644644
);
645645
}
@@ -729,23 +729,23 @@ fn bad_keywords() {
729729
let response = token.enqueue_publish(crate_to_publish);
730730
assert_eq!(response.status(), StatusCode::OK);
731731
assert_eq!(
732-
response.json(),
732+
response.into_json(),
733733
json!({ "errors": [{ "detail": "invalid upload request: invalid length 29, expected a keyword with less than 20 characters at line 1 column 203" }] })
734734
);
735735

736736
let crate_to_publish = PublishBuilder::new("foo_bad_key").keyword("?@?%");
737737
let response = token.enqueue_publish(crate_to_publish);
738738
assert_eq!(response.status(), StatusCode::OK);
739739
assert_eq!(
740-
response.json(),
740+
response.into_json(),
741741
json!({ "errors": [{ "detail": "invalid upload request: invalid value: string \"?@?%\", expected a valid keyword specifier at line 1 column 178" }] })
742742
);
743743

744744
let crate_to_publish = PublishBuilder::new("foo_bad_key").keyword("áccênts");
745745
let response = token.enqueue_publish(crate_to_publish);
746746
assert_eq!(response.status(), StatusCode::OK);
747747
assert_eq!(
748-
response.json(),
748+
response.into_json(),
749749
json!({ "errors": [{ "detail": "invalid upload request: invalid value: string \"áccênts\", expected a valid keyword specifier at line 1 column 183" }] })
750750
);
751751
}
@@ -856,7 +856,7 @@ fn license_and_description_required() {
856856
let response = token.enqueue_publish(crate_to_publish);
857857
assert_eq!(response.status(), StatusCode::OK);
858858
assert_eq!(
859-
response.json(),
859+
response.into_json(),
860860
json!({ "errors": [{ "detail": missing_metadata_error_message(&["description", "license"]) }] })
861861
);
862862

@@ -867,7 +867,7 @@ fn license_and_description_required() {
867867
let response = token.enqueue_publish(crate_to_publish);
868868
assert_eq!(response.status(), StatusCode::OK);
869869
assert_eq!(
870-
response.json(),
870+
response.into_json(),
871871
json!({ "errors": [{ "detail": missing_metadata_error_message(&["description"]) }] })
872872
);
873873

@@ -880,7 +880,7 @@ fn license_and_description_required() {
880880
let response = token.enqueue_publish(crate_to_publish);
881881
assert_eq!(response.status(), StatusCode::OK);
882882
assert_eq!(
883-
response.json(),
883+
response.into_json(),
884884
json!({ "errors": [{ "detail": missing_metadata_error_message(&["description"]) }] })
885885
);
886886
}
@@ -907,7 +907,7 @@ fn new_krate_tarball_with_hard_links() {
907907
let response = token.enqueue_publish(crate_to_publish);
908908
assert_eq!(response.status(), StatusCode::OK);
909909
assert_eq!(
910-
response.json(),
910+
response.into_json(),
911911
json!({ "errors": [{ "detail": "invalid tarball uploaded" }] })
912912
);
913913
}

src/tests/krate/search.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,15 +807,15 @@ fn pagination_parameters_only_accept_integers() {
807807
anon.get_with_query::<()>("/api/v1/crates", "page=1&per_page=100%22%EF%BC%8Cexception");
808808
assert_eq!(response.status(), StatusCode::BAD_REQUEST);
809809
assert_eq!(
810-
response.json(),
810+
response.into_json(),
811811
json!({ "errors": [{ "detail": "invalid digit found in string" }] })
812812
);
813813

814814
let response =
815815
anon.get_with_query::<()>("/api/v1/crates", "page=100%22%EF%BC%8Cexception&per_page=1");
816816
assert_eq!(response.status(), StatusCode::BAD_REQUEST);
817817
assert_eq!(
818-
response.json(),
818+
response.into_json(),
819819
json!({ "errors": [{ "detail": "invalid digit found in string" }] })
820820
);
821821
}

src/tests/krate/yanking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fn yank_by_a_non_owner_fails() {
113113
let response = token.yank("foo_not", "1.0.0");
114114
assert_eq!(response.status(), StatusCode::OK);
115115
assert_eq!(
116-
response.json(),
116+
response.into_json(),
117117
json!({ "errors": [{ "detail": "must already be an owner to yank or unyank" }] })
118118
);
119119
}

0 commit comments

Comments
 (0)