Fix errors in Feedly sync unread operations tests

Yet more completion blocks with Results; apply the usual
do/catch/Result.get() dance.
This commit is contained in:
Tim Ekl 2019-12-31 19:27:47 -06:00
parent 13b227a461
commit 152b1f2b8a
1 changed files with 26 additions and 11 deletions

View File

@ -56,10 +56,15 @@ class FeedlySyncUnreadStatusesOperationTests: XCTestCase {
let expectedArticleIds = Set(ids) let expectedArticleIds = Set(ids)
let fetchIdsExpectation = expectation(description: "Fetch Article Ids") let fetchIdsExpectation = expectation(description: "Fetch Article Ids")
account.fetchUnreadArticleIDs { unreadArticleIds in account.fetchUnreadArticleIDs { unreadArticleIdsResult in
let missingIds = expectedArticleIds.subtracting(unreadArticleIds) do {
XCTAssertTrue(missingIds.isEmpty, "These article ids were not marked as unread.") let unreadArticleIds = try unreadArticleIdsResult.get()
fetchIdsExpectation.fulfill() let missingIds = expectedArticleIds.subtracting(unreadArticleIds)
XCTAssertTrue(missingIds.isEmpty, "These article ids were not marked as unread.")
fetchIdsExpectation.fulfill()
} catch let e {
XCTFail("Error checking unread article IDs: \(e)")
}
} }
waitForExpectations(timeout: 2) waitForExpectations(timeout: 2)
} }
@ -93,9 +98,14 @@ class FeedlySyncUnreadStatusesOperationTests: XCTestCase {
waitForExpectations(timeout: 2) waitForExpectations(timeout: 2)
let fetchIdsExpectation = expectation(description: "Fetch Article Ids") let fetchIdsExpectation = expectation(description: "Fetch Article Ids")
account.fetchUnreadArticleIDs { unreadArticleIds in account.fetchUnreadArticleIDs { unreadArticleIdsResult in
XCTAssertTrue(unreadArticleIds.isEmpty) do {
fetchIdsExpectation.fulfill() let unreadArticleIds = try unreadArticleIdsResult.get()
XCTAssertTrue(unreadArticleIds.isEmpty)
fetchIdsExpectation.fulfill()
} catch let e {
XCTFail("Error checking unread article IDs: \(e)")
}
} }
waitForExpectations(timeout: 2) waitForExpectations(timeout: 2)
} }
@ -142,10 +152,15 @@ class FeedlySyncUnreadStatusesOperationTests: XCTestCase {
// Find statuses inserted. // Find statuses inserted.
let expectedArticleIds = Set(service.pages.values.map { $0.ids }.flatMap { $0 }) let expectedArticleIds = Set(service.pages.values.map { $0.ids }.flatMap { $0 })
let fetchIdsExpectation = expectation(description: "Fetch Article Ids") let fetchIdsExpectation = expectation(description: "Fetch Article Ids")
account.fetchUnreadArticleIDs { unreadArticleIds in account.fetchUnreadArticleIDs { unreadArticleIdsResult in
let missingIds = expectedArticleIds.subtracting(unreadArticleIds) do {
XCTAssertTrue(missingIds.isEmpty, "These article ids were not marked as unread.") let unreadArticleIds = try unreadArticleIdsResult.get()
fetchIdsExpectation.fulfill() let missingIds = expectedArticleIds.subtracting(unreadArticleIds)
XCTAssertTrue(missingIds.isEmpty, "These article ids were not marked as unread.")
fetchIdsExpectation.fulfill()
} catch let e {
XCTFail("Error checking unread article IDs: \(e)")
}
} }
waitForExpectations(timeout: 2) waitForExpectations(timeout: 2)
} }