Skip to content

Commit 01feffb

Browse files
author
Juan López
committed
Guarantee load delivers connectivity error on client error
1 parent df5d2b7 commit 01feffb

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

FeedAPIChallenge/Feed API/RemoteFeedLoader.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public final class RemoteFeedLoader: FeedLoader {
1919
}
2020

2121
public func load(completion: @escaping (FeedLoader.Result) -> Void) {
22-
client.get(from: url) { _ in }
22+
client.get(from: url) { _ in
23+
completion(.failure(Error.connectivity))
24+
}
2325
}
2426
}

Tests/LoadFeedFromRemoteUseCaseTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ class LoadFeedFromRemoteUseCaseTests: XCTestCase {
3535
XCTAssertEqual(client.requestedURLs, [url, url])
3636
}
3737

38-
// func test_load_deliversConnectivityErrorOnClientError() {
39-
// let (sut, client) = makeSUT()
40-
//
41-
// expect(sut, toCompleteWith: .failure(.connectivity), when: {
42-
// let clientError = NSError(domain: "Test", code: 0)
43-
// client.complete(with: clientError)
44-
// })
45-
// }
46-
//
38+
func test_load_deliversConnectivityErrorOnClientError() {
39+
let (sut, client) = makeSUT()
40+
41+
expect(sut, toCompleteWith: .failure(.connectivity), when: {
42+
let clientError = NSError(domain: "Test", code: 0)
43+
client.complete(with: clientError)
44+
})
45+
}
46+
4747
// func test_load_deliversInvalidDataErrorOnNon200HTTPResponse() {
4848
// let (sut, client) = makeSUT()
4949
//

0 commit comments

Comments
 (0)