-
Notifications
You must be signed in to change notification settings - Fork 2
add allowCompletion to requestBehavior #4
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
base: develop
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #4 +/- ##
===========================================
- Coverage 99% 98.72% -0.28%
===========================================
Files 32 32
Lines 900 939 +39
===========================================
+ Hits 891 927 +36
- Misses 9 12 +3
Continue to review full report at Codecov.
|
| case .cancelled: | ||
| break | ||
| default: | ||
| XCTFail("wrong error returned") |
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 can be rewritten to increase code coverage by testing the success criteria, not putting fails all over the place just-in-case
| } | ||
| } | ||
|
|
||
| func testCancelledBehavior() { |
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.
Where is the test for a cancel request behaviour that returns true?
| webservice.load(resource) { result in | ||
| switch result { | ||
| case .failure(let error): | ||
| if let error = error as? Webservice.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 is incorrect, the requirement, as i understand it from discussion, is to not call the completion block when cancelled (but to call the other behaviours to let them know of the cancellation)
| } | ||
|
|
||
| func allowCompletion(data: Data?, response: URLResponse?, error: Error?) -> Bool { | ||
| return !behaviors.map { $0.allowCompletion(data: data, response: response, error: error) }.contains(false) |
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 can be more efficient, if any return false there is no point processing more
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.
Not sure if this is valid. We don't know what it is in the other behaviours and whether they know about this implementation detail. We also didn't discuss if one behaviour returns true and one returns false, what should we do? E.g. a logging behaviour.
No description provided.