From 711aca3d1b9ba9df5e1effddef8204a9c070bdb8 Mon Sep 17 00:00:00 2001 From: Tim Ekl Date: Tue, 31 Dec 2019 19:29:44 -0600 Subject: [PATCH] Fix build errors in Feedly test support Two more cases of completion blocks taking Results, requiring a do/catch/Result.get() to unwrap. This commit deliberately leaves one build error for a more comprehensive fix, since it occurs in a helper function that will have broader fallout. --- .../Feedly/FeedlyTestSupport.swift | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/Frameworks/Account/AccountTests/Feedly/FeedlyTestSupport.swift b/Frameworks/Account/AccountTests/Feedly/FeedlyTestSupport.swift index 3e5ae30ff..fb52eb781 100644 --- a/Frameworks/Account/AccountTests/Feedly/FeedlyTestSupport.swift +++ b/Frameworks/Account/AccountTests/Feedly/FeedlyTestSupport.swift @@ -220,12 +220,17 @@ class FeedlyTestSupport { func checkUnreadStatuses(in testAccount: Account, correspondToIdsInJSONPayload streamIds: [String: Any], testCase: XCTestCase) { let ids = Set(streamIds["ids"] as! [String]) let fetchIdsExpectation = testCase.expectation(description: "Fetch Article Ids") - testAccount.fetchUnreadArticleIDs { articleIds in - // Unread statuses can be paged from Feedly. - // Instead of joining test data, the best we can do is - // make sure that these ids are marked as unread (a subset of the total). - XCTAssertTrue(ids.isSubset(of: articleIds), "Some articles in `ids` are not marked as unread.") - fetchIdsExpectation.fulfill() + testAccount.fetchUnreadArticleIDs { articleIdsResult in + do { + let articleIds = try articleIdsResult.get() + // Unread statuses can be paged from Feedly. + // Instead of joining test data, the best we can do is + // make sure that these ids are marked as unread (a subset of the total). + XCTAssertTrue(ids.isSubset(of: articleIds), "Some articles in `ids` are not marked as unread.") + fetchIdsExpectation.fulfill() + } catch let e { + XCTFail("Error unwrapping article IDs: \(e)") + } } testCase.wait(for: [fetchIdsExpectation], timeout: 2) } @@ -239,12 +244,17 @@ class FeedlyTestSupport { let items = stream["items"] as! [[String: Any]] let ids = Set(items.map { $0["id"] as! String }) let fetchIdsExpectation = testCase.expectation(description: "Fetch Article Ids") - testAccount.fetchStarredArticleIDs { articleIds in - // Starred articles can be paged from Feedly. - // Instead of joining test data, the best we can do is - // make sure that these articles are marked as starred (a subset of the total). - XCTAssertTrue(ids.isSubset(of: articleIds), "Some articles in `ids` are not marked as starred.") - fetchIdsExpectation.fulfill() + testAccount.fetchStarredArticleIDs { articleIdsResult in + do { + let articleIds = try articleIdsResult.get() + // Starred articles can be paged from Feedly. + // Instead of joining test data, the best we can do is + // make sure that these articles are marked as starred (a subset of the total). + XCTAssertTrue(ids.isSubset(of: articleIds), "Some articles in `ids` are not marked as starred.") + fetchIdsExpectation.fulfill() + } catch let e { + XCTFail("Error unwrapping article IDs: \(e)") + } } testCase.wait(for: [fetchIdsExpectation], timeout: 2) }