Skip to content

Commit

Permalink
Use built-in Result initializer to simplify Result mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
finebel committed May 1, 2024
1 parent 31cda2e commit 0d2bf5e
Showing 1 changed file with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ class EssentialFeedAPIEndToEndTests: XCTestCase {
var receivedResult: Swift.Result<[FeedImage], Error>?
client.get(from: feedTestServerURL) { result in
receivedResult = result.flatMap { (data, response) in
do {
return .success(try FeedItemsMapper.map(data, from: response))
} catch {
return .failure(error)
}
Result { try FeedItemsMapper.map(data, from: response) }
}
exp.fulfill()
}
Expand All @@ -71,11 +67,7 @@ class EssentialFeedAPIEndToEndTests: XCTestCase {
var receivedResult: Result<Data, Error>?
client.get(from: url) { result in
receivedResult = result.flatMap { (data, response) in
do {
return .success(try FeedImageDataMapper.map(data, from: response))
} catch {
return .failure(error)
}
Result { try FeedImageDataMapper.map(data, from: response) }
}
exp.fulfill()
}
Expand Down

0 comments on commit 0d2bf5e

Please sign in to comment.