-
Notifications
You must be signed in to change notification settings - Fork 121
[REST API] Merge WordPressOrgRequest into RESTRequest
#8553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
You can test the changes from this Pull Request by:
|
itsmeichigo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I left a question regarding the tests.
| /// Verifies that RESTRequest request doesn't parse WordPressApiError | ||
| /// | ||
| func test_wordpress_org_request_parses_wordpress_api_error() async throws { | ||
| func test_wordpress_org_request_does_not_parse_wordpress_api_error() async throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this test case, should the request parse the error though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original test case validated that WordPressApiValidator is used in WordPressOrgRequest.
In RESTRequest we decided to use PlaceholderDataValidator which will not validate the request. So, I updated the test case to check that no errors are parsed.
i.e. test_wordpress_org_request_does_not_parse_wordpress_api_error and test_wordpress_org_request_does_not_parse_dotcom_error will ensure that PlaceholderDataValidator is used.
| let result = try await remote.enqueue(request, mapper: mapper) | ||
|
|
||
| // Then | ||
| XCTAssertNotNil(result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check that result is failure because we are mocking a timeout error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed this pattern from the test_wordpress_org_request_does_not_parse_dotcom_error method.
The idea here is ensure try await remote.enqueue(request, mapper: mapper) doesn't throw any error.
Please note that the result is of type Data from DummyMapper, and not of Swift.Result<Data, Error> type.
|
Thank you for the review, Huong! 🙇 I am going ahead and merging this now. I will make changes to the unit tests if anything comes up from our PR review discussions. |
Closes: #8512
Description
WordPressOrgRequestandRESTRequesthave similar properties. For clarity we decided to merge them both and useRESTRequest.Testing instructions
WordPressOrgRequest(deleted in this PR) andRESTRequestare being used.Jetpack installation
Application password
applicationPasswordAuthenticationForSiteCredentialLoginfeature flag.Screenshots
NA
RELEASE-NOTES.txtif necessary.