add allowCompletion to requestBehavior#4
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.
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.
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.
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.
this can be more efficient, if any return false there is no point processing more
There was a problem hiding this comment.
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.