fix missing connect timeout and make tests safer#267
Merged
artemredkin merged 7 commits intoJun 22, 2020
Conversation
artemredkin
commented
Jun 19, 2020
| XCTFail("Error should have been ChannelError.connectTimeout not \(type(of: error))") | ||
| XCTAssertThrowsError(try httpClient.get(url: "https://localhost:\(port)/get").wait()) { error in | ||
| switch error { | ||
| case ChannelError.connectTimeout(let timeout): |
Collaborator
Author
There was a problem hiding this comment.
@weissi do you know if there is a safer pattern for this case, where enum has an associated value?
Collaborator
There was a problem hiding this comment.
What don't you like about this pattern?
Collaborator
Author
There was a problem hiding this comment.
This is potentially dangerous, if you miss the XCTFail call in the default clause, you might miss when the test breaks. This is why I'm replacing do-try-XCTFail-catch pattern with XCTAssertThrowsError
Collaborator
There was a problem hiding this comment.
I see what you mean. No, there isn't really a better pattern here sadly.
Contributor
There was a problem hiding this comment.
I usually do this
XCTAssertEqul(.connectTimeout(.milliSeconds(150)), error as? ChannelError)
as it's much safer
artemredkin
commented
Jun 19, 2020
Collaborator
Author
|
failed due to #265 |
Collaborator
Author
|
@swift-server-bot test this please |
Lukasa
approved these changes
Jun 22, 2020
artemredkin
added a commit
to artemredkin/async-http-client
that referenced
this pull request
Jun 23, 2020
* fix missing connect timeout and make tests safer * swiftformat and linux tests * fix timeout test * speedup another test * make tests safer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix missing connect timeout and make some tests faster and safer.
Motivation:
testConnectionFailErroris slow, 10 seconds, due to not having a timeout settestConnectionFailErrorandtestTLSVersionErroruse dangerousdo-try-XCFail-catchpatternModifications:
testTLSVersionErrorfasterXCTAssertThrowsErrorintestConnectionFailErrorandtestTLSVersionErrortestConnectionFailErroris NIOTS-specific.Result:
Fixes an issue where connection timeout configuration was not respected, hopefully makes tests more robust