-
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
Changes from all commits
0925eea
e4a91e9
43d6afc
b587839
02c0278
5915f46
5b9705b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -423,28 +423,32 @@ final class RemoteTests: XCTestCase { | |
| XCTAssertNotNil(result) | ||
| } | ||
|
|
||
| /// Verifies that WordPressOrg request parses WordPressApiError | ||
| /// 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 { | ||
| // Given | ||
| let network = MockNetwork() | ||
| let mapper = DummyMapper() | ||
| let remote = Remote(network: network) | ||
| let request = WordPressOrgRequest(baseURL: "https://example.com", method: .get, path: "mock") | ||
| let request = RESTRequest(siteURL: "https://example.com", method: .get, path: "mock") | ||
|
|
||
| network.simulateResponse(requestUrlSuffix: "mock", filename: "error-wp-rest-forbidden") | ||
| network.simulateResponse(requestUrlSuffix: "mock", filename: "timeout_error") | ||
|
|
||
| await assertThrowsError({ _ = try await remote.enqueue(request, mapper: mapper)}, errorAssert: { $0 is WordPressApiError }) | ||
| // When | ||
| let result = try await remote.enqueue(request, mapper: mapper) | ||
|
|
||
| // Then | ||
| XCTAssertNotNil(result) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we check that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I followed this pattern from the The idea here is ensure Please note that the |
||
| } | ||
|
|
||
| /// Verifies that WordPressOrg request doesn't parse DotcomError | ||
| /// Verifies that RESTRequest request doesn't parse DotcomError | ||
| /// | ||
| func test_wordpress_org_request_does_not_parse_dotcom_error() async throws { | ||
| // Given | ||
| let network = MockNetwork() | ||
| let mapper = DummyMapper() | ||
| let remote = Remote(network: network) | ||
| let request = WordPressOrgRequest(baseURL: "https://example.com", method: .get, path: "mock") | ||
| let request = RESTRequest(siteURL: "https://example.com", method: .get, path: "mock") | ||
|
|
||
| network.simulateResponse(requestUrlSuffix: "mock", filename: "timeout_error") | ||
|
|
||
|
|
||
This file was deleted.
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
WordPressApiValidatoris used inWordPressOrgRequest.In
RESTRequestwe decided to usePlaceholderDataValidatorwhich 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_errorandtest_wordpress_org_request_does_not_parse_dotcom_errorwill ensure thatPlaceholderDataValidatoris used.