-
Notifications
You must be signed in to change notification settings - Fork 25
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
HTTP Paginated Response #783
Conversation
This slipped through the cracks of this PR https://github.com/ably/ably-ios/pull/777/files
Fix RSC7b test
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 left some observations. Nothing major, but I think it's worth making those clear before merging.
userCallback(result, 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.
This if
looks the same as implemented in first:
. Worth extracting it in separate method?
Source/ARTHTTPPaginatedResponse.m
Outdated
|
||
ARTHTTPPaginatedResponse *result = [[ARTHTTPPaginatedResponse alloc] initWithResponse:response items:items rest:rest relFirst:firstRel relCurrent:currentRel relNext:nextRel responseProcessor:responseProcessor]; | ||
|
||
callback(result, [ARTErrorInfo createFromNSError: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 don't understand why the error is passed along here. Shouldn't it be nil?
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 changed it 861f32b. Thanks
fail("First link isn't a valid URL"); return | ||
} | ||
|
||
expect(firstRequest.url?.absoluteString).to(equal("https://sandbox-rest.ably.io:443/channels/foo/messages?start=0&end=1535035746063&limit=100&direction=backwards&format=msgpack&firstEnd=1535035746063&fromDate=1535035746063&mode=all")) |
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.
Same here.
} | ||
} | ||
} | ||
} |
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.
Can we have also tests for next and last?
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.
Hmm, that's a good point but we need something to respond with the ref next and last links.
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 major one is likely the direct reference to "sandbox"
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.
See comment
Spec/RestClient.swift
Outdated
guard let error = error else { | ||
fail("Error is nil"); done(); return | ||
fail("Error is empty"); done(); return |
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 why you expect there to be an error in this case. The semantics of this method is that the request was made, and there was a response, and that's that. There was no error.
The response includes a statusCode that is an "error" result, but the request itself didn't fail. It succeeded, and returned a result.
Also, pls can we have tests for requests that do indeed fail - for example it times out, fails to resolve the host, returns a response body that cannot be parsed, etc.
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.
@paddybyers this is making a GET /feature
which doesn't exist, so the request fails and the error should not be nil. This guard
simply makes the test fail if the error is nil.
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.
No, that's not right. If the server responds to the request, and that response is well-formed (even though it is a 404), then that counts as success in this API. There is no error
, but the response, encapsulated in the HttpPaginatedResponse
, will indicate that the content of the response was an error, appropriately populating success
, statusCode
, errorCode
and errorMessage
.
RSC19e states that this method does result in an error if the server did not respond, or its response was not well-formed in some way, so it was not possible to return a HttpPaginatedResponse
.
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.
Oh I see now. So the error in nested in the pagination block of the response, not on the first level of the returned object.
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.
No, that's not right. If the server responds to the request, and that response is well-formed (even though it is a 404), then that counts as success in this API. There is no
error
, but the response, encapsulated in theHttpPaginatedResponse
, will indicate that the content of the response was an error, appropriately populatingsuccess
,statusCode
,errorCode
anderrorMessage
.
That makes it clear, yes. Thanks. I'll fix it.
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.
Fixed 63ebbf5.
Spec/RestClient.swift
Outdated
guard let paginatedResponse = paginatedResponse else { | ||
fail("PaginatedResult is empty"); done(); return | ||
} | ||
expect(error.statusCode) == 404 |
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.
Why are there no corresponding assertions for the properties of paginatedResponse
?
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.
@paddybyers There already exist at the bottom. Did you miss them? https://github.com/ably/ably-ios/blob/63ebbf5a24d5807a19e07ddbfb2de0e9e65def24/Spec/RestClient.swift#L1642-L1647
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.
Yes :(
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.
@paddybyers 😄 So we're good?
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, thanks
No description provided.