@@ -6,7 +6,6 @@ use crates_io_database::schema::trustpub_configs_github;
66use crates_io_github:: { GitHubError , GitHubUser , MockGitHubClient } ;
77use diesel:: prelude:: * ;
88use diesel_async:: RunQueryDsl ;
9- use http:: StatusCode ;
109use insta:: { assert_json_snapshot, assert_snapshot} ;
1110use serde_json:: json;
1211
@@ -61,7 +60,7 @@ async fn test_happy_path() -> anyhow::Result<()> {
6160 } ) ) ?;
6261
6362 let ( app, response) = run_test ( body) . await ;
64- assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
63+ assert_snapshot ! ( response. status( ) , @ "200 OK" ) ;
6564 assert_json_snapshot ! ( response. json( ) , { ".github_config.created_at" => "[datetime]" } ) ;
6665
6766 assert_snapshot ! ( app. emails_snapshot( ) . await ) ;
@@ -91,7 +90,7 @@ async fn test_happy_path_with_environment() -> anyhow::Result<()> {
9190 } ) ) ?;
9291
9392 let ( _app, response) = run_test ( body) . await ;
94- assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
93+ assert_snapshot ! ( response. status( ) , @ "200 OK" ) ;
9594 assert_json_snapshot ! ( response. json( ) , { ".github_config.created_at" => "[datetime]" } ) ;
9695
9796 Ok ( ( ) )
@@ -100,7 +99,7 @@ async fn test_happy_path_with_environment() -> anyhow::Result<()> {
10099#[ tokio:: test( flavor = "multi_thread" ) ]
101100async fn test_empty_body ( ) -> anyhow:: Result < ( ) > {
102101 let ( _app, response) = run_test ( "" ) . await ;
103- assert_eq ! ( response. status( ) , StatusCode :: UNSUPPORTED_MEDIA_TYPE ) ;
102+ assert_snapshot ! ( response. status( ) , @ "415 Unsupported Media Type" ) ;
104103 assert_snapshot ! ( response. text( ) , @r#"{"errors":[{"detail":"Expected request with `Content-Type: application/json`"}]}"# ) ;
105104
106105 Ok ( ( ) )
@@ -109,7 +108,7 @@ async fn test_empty_body() -> anyhow::Result<()> {
109108#[ tokio:: test( flavor = "multi_thread" ) ]
110109async fn test_empty_json_object ( ) -> anyhow:: Result < ( ) > {
111110 let ( _app, response) = run_test ( "{}" ) . await ;
112- assert_eq ! ( response. status( ) , StatusCode :: UNPROCESSABLE_ENTITY ) ;
111+ assert_snapshot ! ( response. status( ) , @ "422 Unprocessable Entity" ) ;
113112 assert_snapshot ! ( response. text( ) , @r#"{"errors":[{"detail":"Failed to deserialize the JSON body into the target type: missing field `github_config` at line 1 column 2"}]}"# ) ;
114113
115114 Ok ( ( ) )
@@ -128,7 +127,7 @@ async fn test_invalid_owner() -> anyhow::Result<()> {
128127 } ) ) ?;
129128
130129 let ( _app, response) = run_test ( body) . await ;
131- assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
130+ assert_snapshot ! ( response. status( ) , @ "400 Bad Request" ) ;
132131 assert_snapshot ! ( response. text( ) , @r#"{"errors":[{"detail":"Invalid GitHub repository owner name"}]}"# ) ;
133132
134133 Ok ( ( ) )
@@ -147,7 +146,7 @@ async fn test_invalid_repo() -> anyhow::Result<()> {
147146 } ) ) ?;
148147
149148 let ( _app, response) = run_test ( body) . await ;
150- assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
149+ assert_snapshot ! ( response. status( ) , @ "400 Bad Request" ) ;
151150 assert_snapshot ! ( response. text( ) , @r#"{"errors":[{"detail":"Invalid GitHub repository name"}]}"# ) ;
152151
153152 Ok ( ( ) )
@@ -166,7 +165,7 @@ async fn test_invalid_workflow() -> anyhow::Result<()> {
166165 } ) ) ?;
167166
168167 let ( _app, response) = run_test ( body) . await ;
169- assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
168+ assert_snapshot ! ( response. status( ) , @ "400 Bad Request" ) ;
170169 assert_snapshot ! ( response. text( ) , @r#"{"errors":[{"detail":"Workflow filename must end with `.yml` or `.yaml`"}]}"# ) ;
171170
172171 Ok ( ( ) )
@@ -185,7 +184,7 @@ async fn test_invalid_environment() -> anyhow::Result<()> {
185184 } ) ) ?;
186185
187186 let ( _app, response) = run_test ( body) . await ;
188- assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
187+ assert_snapshot ! ( response. status( ) , @ "400 Bad Request" ) ;
189188 assert_snapshot ! ( response. text( ) , @r#"{"errors":[{"detail":"Environment name may not be empty (use `null` to omit)"}]}"# ) ;
190189
191190 Ok ( ( ) )
@@ -215,7 +214,7 @@ async fn test_unauthenticated() -> anyhow::Result<()> {
215214 } ) ) ?;
216215
217216 let response = client. put :: < ( ) > ( URL , body) . await ;
218- assert_eq ! ( response. status( ) , StatusCode :: FORBIDDEN ) ;
217+ assert_snapshot ! ( response. status( ) , @ "403 Forbidden" ) ;
219218 assert_snapshot ! ( response. text( ) , @r#"{"errors":[{"detail":"this action requires authentication"}]}"# ) ;
220219
221220 Ok ( ( ) )
@@ -245,7 +244,7 @@ async fn test_token_auth() -> anyhow::Result<()> {
245244 } ) ) ?;
246245
247246 let response = token_client. put :: < ( ) > ( URL , body) . await ;
248- assert_eq ! ( response. status( ) , StatusCode :: FORBIDDEN ) ;
247+ assert_snapshot ! ( response. status( ) , @ "403 Forbidden" ) ;
249248 assert_snapshot ! ( response. text( ) , @r#"{"errors":[{"detail":"this action can only be performed on the crates.io website"}]}"# ) ;
250249
251250 Ok ( ( ) )
@@ -269,7 +268,7 @@ async fn test_missing_crate() -> anyhow::Result<()> {
269268 } ) ) ?;
270269
271270 let response = cookie_client. put :: < ( ) > ( URL , body) . await ;
272- assert_eq ! ( response. status( ) , StatusCode :: NOT_FOUND ) ;
271+ assert_snapshot ! ( response. status( ) , @ "404 Not Found" ) ;
273272 assert_snapshot ! ( response. text( ) , @r#"{"errors":[{"detail":"crate `foo` does not exist"}]}"# ) ;
274273
275274 Ok ( ( ) )
@@ -301,7 +300,7 @@ async fn test_non_owner() -> anyhow::Result<()> {
301300 } ) ) ?;
302301
303302 let response = other_client. put :: < ( ) > ( URL , body) . await ;
304- assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
303+ assert_snapshot ! ( response. status( ) , @ "400 Bad Request" ) ;
305304 assert_snapshot ! ( response. text( ) , @r#"{"errors":[{"detail":"You are not an owner of this crate"}]}"# ) ;
306305
307306 Ok ( ( ) )
@@ -333,7 +332,7 @@ async fn test_unknown_github_user() -> anyhow::Result<()> {
333332 } ) ) ?;
334333
335334 let response = cookie_client. put :: < ( ) > ( URL , body) . await ;
336- assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
335+ assert_snapshot ! ( response. status( ) , @ "400 Bad Request" ) ;
337336 assert_snapshot ! ( response. text( ) , @r#"{"errors":[{"detail":"Unknown GitHub user or organization"}]}"# ) ;
338337
339338 Ok ( ( ) )
@@ -365,7 +364,7 @@ async fn test_github_error() -> anyhow::Result<()> {
365364 } ) ) ?;
366365
367366 let response = cookie_client. put :: < ( ) > ( URL , body) . await ;
368- assert_eq ! ( response. status( ) , StatusCode :: INTERNAL_SERVER_ERROR ) ;
367+ assert_snapshot ! ( response. status( ) , @ "500 Internal Server Error" ) ;
369368 assert_snapshot ! ( response. text( ) , @r#"{"errors":[{"detail":"Internal Server Error"}]}"# ) ;
370369
371370 Ok ( ( ) )
0 commit comments