Refactor tests to improve response parsing and validation
- Introduced a new common module with response helper functions to streamline response parsing across tests. - Updated role controller tests to assert success messages in responses for create, update, and delete operations. - Enhanced role service tests to validate response structures and ensure proper error handling. - Modified team controller and service tests to check for success messages and validate response data formats. - Improved user controller and service tests to include success message assertions and error handling for invalid inputs. - Ensured all tests utilize the new response parsing functions for consistency and maintainability.
This commit is contained in:
1 parent
a32f54873b
commit
9cecc8fa05
25 files changed
+893
-512
No files matched your search
@@ -182,8 +182,8 @@ mod tests {
|
||||
let response = app.oneshot(request).await.unwrap();
|
||||
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
let body = response.into_body().collect().await.unwrap().to_bytes();
|
||||
let json_body: AuthLoginResponsetDto = serde_json::from_slice(&body).unwrap();
|
||||
let json_body: AuthLoginResponsetDto =
|
||||
crate::common::response_helpers::parse_response(response, 8192).await;
|
||||
assert_eq!(json_body.token.access_token, expected_access_token);
|
||||
assert_eq!(json_body.token.refresh_token, expected_refresh_token);
|
||||
assert_eq!(json_body.user.email, user_email);
|
||||
@@ -271,8 +271,8 @@ mod tests {
|
||||
let response = app.oneshot(request).await.unwrap();
|
||||
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
let body = response.into_body().collect().await.unwrap().to_bytes();
|
||||
let json_body: AuthLoginResponsetDto = serde_json::from_slice(&body).unwrap();
|
||||
let json_body: AuthLoginResponsetDto =
|
||||
crate::common::response_helpers::parse_response(response, 8192).await;
|
||||
assert_eq!(json_body.token.access_token, expected_access_token);
|
||||
assert_eq!(json_body.token.refresh_token, expected_refresh_token);
|
||||
assert_eq!(json_body.user.email, user_email);
|
||||
|
||||
Reference in new issue
Block a user