Fix build errors stemming from FeedlyTestSupport
There was one call to a throwing function inside `checkArticles(in:correspondToStreamItemsIn:)` which was not appropriately marked with `try`. Add that keyword, and then bubble out the chain of errors through additional layers of helpers to the enclosing test: * This `checkArticles` variant was called by two others * …one of which was used in `testAddNewFeedSuccess()` * …another of which was used in various `verify` sync helpers * …which were referenced from `testSyncing()`, a test case method None of these involved any particular async hoops to jump through, and since the top-level callers were all test functions, we can count on XCTest to handle any errors thrown — no additional `catch` or handling on our part is necessary.
This commit is contained in:
parent
711aca3d1b
commit
6c10774c4a
@ -120,7 +120,7 @@ class FeedlyAddNewFeedOperationTests: XCTestCase {
|
|||||||
XCTAssert(progress.isComplete)
|
XCTAssert(progress.isComplete)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAddNewFeedSuccess() {
|
func testAddNewFeedSuccess() throws {
|
||||||
guard let folder = getFolderByLoadingInitialContent() else {
|
guard let folder = getFolderByLoadingInitialContent() else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ class FeedlyAddNewFeedOperationTests: XCTestCase {
|
|||||||
|
|
||||||
XCTAssert(progress.isComplete)
|
XCTAssert(progress.isComplete)
|
||||||
|
|
||||||
support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "feedStream", subdirectory: subdirectory)
|
try support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "feedStream", subdirectory: subdirectory)
|
||||||
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds", subdirectory: subdirectory, testCase: self)
|
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds", subdirectory: subdirectory, testCase: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,18 +114,18 @@ class FeedlySyncAllOperationTests: XCTestCase {
|
|||||||
return caller
|
return caller
|
||||||
}()
|
}()
|
||||||
|
|
||||||
func testSyncing() {
|
func testSyncing() throws {
|
||||||
performInitialSync()
|
performInitialSync()
|
||||||
verifyInitialSync()
|
try verifyInitialSync()
|
||||||
|
|
||||||
performChangeStatuses()
|
performChangeStatuses()
|
||||||
verifyChangeStatuses()
|
try verifyChangeStatuses()
|
||||||
|
|
||||||
performChangeStatusesAgain()
|
performChangeStatusesAgain()
|
||||||
verifyChangeStatusesAgain()
|
try verifyChangeStatusesAgain()
|
||||||
|
|
||||||
performAddFeedsAndFolders()
|
performAddFeedsAndFolders()
|
||||||
verifyAddFeedsAndFolders()
|
try verifyAddFeedsAndFolders()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: 1 - Initial Sync
|
// MARK: 1 - Initial Sync
|
||||||
@ -166,15 +166,15 @@ class FeedlySyncAllOperationTests: XCTestCase {
|
|||||||
loadMockData(inSubdirectoryNamed: "feedly-1-initial")
|
loadMockData(inSubdirectoryNamed: "feedly-1-initial")
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyInitialSync() {
|
func verifyInitialSync() throws {
|
||||||
let subdirectory = "feedly-1-initial"
|
let subdirectory = "feedly-1-initial"
|
||||||
support.checkFoldersAndFeeds(in: account, againstCollectionsAndFeedsInJSONNamed: "collections", subdirectory: subdirectory)
|
support.checkFoldersAndFeeds(in: account, againstCollectionsAndFeedsInJSONNamed: "collections", subdirectory: subdirectory)
|
||||||
support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "global.all", subdirectory: subdirectory)
|
try support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "global.all", subdirectory: subdirectory)
|
||||||
support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "global.all@MTZkOTdkZWQ1NzM6NTE2OjUzYjgyNmEy", subdirectory: subdirectory)
|
try support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "global.all@MTZkOTdkZWQ1NzM6NTE2OjUzYjgyNmEy", subdirectory: subdirectory)
|
||||||
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds", subdirectory: subdirectory, testCase: self)
|
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds", subdirectory: subdirectory, testCase: self)
|
||||||
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds@MTZkOTRhOTNhZTQ6MzExOjUzYjgyNmEy", subdirectory: subdirectory, testCase: self)
|
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds@MTZkOTRhOTNhZTQ6MzExOjUzYjgyNmEy", subdirectory: subdirectory, testCase: self)
|
||||||
support.checkStarredStatuses(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory, testCase: self)
|
support.checkStarredStatuses(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory, testCase: self)
|
||||||
support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory)
|
try support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: 2 - Change Statuses
|
// MARK: 2 - Change Statuses
|
||||||
@ -183,14 +183,14 @@ class FeedlySyncAllOperationTests: XCTestCase {
|
|||||||
loadMockData(inSubdirectoryNamed: "feedly-2-changestatuses")
|
loadMockData(inSubdirectoryNamed: "feedly-2-changestatuses")
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyChangeStatuses() {
|
func verifyChangeStatuses() throws {
|
||||||
let subdirectory = "feedly-2-changestatuses"
|
let subdirectory = "feedly-2-changestatuses"
|
||||||
support.checkFoldersAndFeeds(in: account, againstCollectionsAndFeedsInJSONNamed: "collections", subdirectory: subdirectory)
|
support.checkFoldersAndFeeds(in: account, againstCollectionsAndFeedsInJSONNamed: "collections", subdirectory: subdirectory)
|
||||||
support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "global.all", subdirectory: subdirectory)
|
try support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "global.all", subdirectory: subdirectory)
|
||||||
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds", subdirectory: subdirectory, testCase: self)
|
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds", subdirectory: subdirectory, testCase: self)
|
||||||
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds@MTZkOTJkNjIwM2Q6MTEzYjpkNDUwNjA3MQ==", subdirectory: subdirectory, testCase: self)
|
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds@MTZkOTJkNjIwM2Q6MTEzYjpkNDUwNjA3MQ==", subdirectory: subdirectory, testCase: self)
|
||||||
support.checkStarredStatuses(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory, testCase: self)
|
support.checkStarredStatuses(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory, testCase: self)
|
||||||
support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory)
|
try support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: 3 - Change Statuses Again
|
// MARK: 3 - Change Statuses Again
|
||||||
@ -199,14 +199,14 @@ class FeedlySyncAllOperationTests: XCTestCase {
|
|||||||
loadMockData(inSubdirectoryNamed: "feedly-3-changestatusesagain")
|
loadMockData(inSubdirectoryNamed: "feedly-3-changestatusesagain")
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyChangeStatusesAgain() {
|
func verifyChangeStatusesAgain() throws {
|
||||||
let subdirectory = "feedly-3-changestatusesagain"
|
let subdirectory = "feedly-3-changestatusesagain"
|
||||||
support.checkFoldersAndFeeds(in: account, againstCollectionsAndFeedsInJSONNamed: "collections", subdirectory: subdirectory)
|
support.checkFoldersAndFeeds(in: account, againstCollectionsAndFeedsInJSONNamed: "collections", subdirectory: subdirectory)
|
||||||
support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "global.all", subdirectory: subdirectory)
|
try support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "global.all", subdirectory: subdirectory)
|
||||||
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds", subdirectory: subdirectory, testCase: self)
|
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds", subdirectory: subdirectory, testCase: self)
|
||||||
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds@MTZkOGRlMjVmM2M6M2YyOmQ0NTA2MDcx", subdirectory: subdirectory, testCase: self)
|
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds@MTZkOGRlMjVmM2M6M2YyOmQ0NTA2MDcx", subdirectory: subdirectory, testCase: self)
|
||||||
support.checkStarredStatuses(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory, testCase: self)
|
support.checkStarredStatuses(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory, testCase: self)
|
||||||
support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory)
|
try support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: 4 - Add Feeds and Folders
|
// MARK: 4 - Add Feeds and Folders
|
||||||
@ -215,14 +215,14 @@ class FeedlySyncAllOperationTests: XCTestCase {
|
|||||||
loadMockData(inSubdirectoryNamed: "feedly-4-addfeedsandfolders")
|
loadMockData(inSubdirectoryNamed: "feedly-4-addfeedsandfolders")
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyAddFeedsAndFolders() {
|
func verifyAddFeedsAndFolders() throws {
|
||||||
let subdirectory = "feedly-4-addfeedsandfolders"
|
let subdirectory = "feedly-4-addfeedsandfolders"
|
||||||
support.checkFoldersAndFeeds(in: account, againstCollectionsAndFeedsInJSONNamed: "collections", subdirectory: subdirectory)
|
support.checkFoldersAndFeeds(in: account, againstCollectionsAndFeedsInJSONNamed: "collections", subdirectory: subdirectory)
|
||||||
support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "global.all", subdirectory: subdirectory)
|
try support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "global.all", subdirectory: subdirectory)
|
||||||
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds", subdirectory: subdirectory, testCase: self)
|
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds", subdirectory: subdirectory, testCase: self)
|
||||||
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds@MTZkOTE3YTRlMzQ6YWZjOmQ0NTA2MDcx", subdirectory: subdirectory, testCase: self)
|
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds@MTZkOTE3YTRlMzQ6YWZjOmQ0NTA2MDcx", subdirectory: subdirectory, testCase: self)
|
||||||
support.checkStarredStatuses(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory, testCase: self)
|
support.checkStarredStatuses(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory, testCase: self)
|
||||||
support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory)
|
try support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: 5 - Remove Feeds and Folders
|
// MARK: 5 - Remove Feeds and Folders
|
||||||
@ -231,14 +231,14 @@ class FeedlySyncAllOperationTests: XCTestCase {
|
|||||||
loadMockData(inSubdirectoryNamed: "feedly-5-removefeedsandfolders")
|
loadMockData(inSubdirectoryNamed: "feedly-5-removefeedsandfolders")
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyRemoveFeedsAndFolders() {
|
func verifyRemoveFeedsAndFolders() throws {
|
||||||
let subdirectory = "feedly-5-removefeedsandfolders"
|
let subdirectory = "feedly-5-removefeedsandfolders"
|
||||||
support.checkFoldersAndFeeds(in: account, againstCollectionsAndFeedsInJSONNamed: "collections", subdirectory: subdirectory)
|
support.checkFoldersAndFeeds(in: account, againstCollectionsAndFeedsInJSONNamed: "collections", subdirectory: subdirectory)
|
||||||
support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "global.all", subdirectory: subdirectory)
|
try support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "global.all", subdirectory: subdirectory)
|
||||||
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds", subdirectory: subdirectory, testCase: self)
|
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds", subdirectory: subdirectory, testCase: self)
|
||||||
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds@MTZkOGRlMjVmM2M6M2YxOmQ0NTA2MDcx", subdirectory: subdirectory, testCase: self)
|
support.checkUnreadStatuses(in: account, againstIdsInStreamInJSONNamed: "unreadIds@MTZkOGRlMjVmM2M6M2YxOmQ0NTA2MDcx", subdirectory: subdirectory, testCase: self)
|
||||||
support.checkStarredStatuses(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory, testCase: self)
|
support.checkStarredStatuses(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory, testCase: self)
|
||||||
support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory)
|
try support.checkArticles(in: account, againstItemsInStreamInJSONNamed: "starred", subdirectory: subdirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Downloading Test Data
|
// MARK: Downloading Test Data
|
||||||
|
@ -141,13 +141,13 @@ class FeedlyTestSupport {
|
|||||||
XCTAssertTrue(missingFeedIds.isEmpty, "Feeds with these ids were not found in the \"\(label)\" folder.")
|
XCTAssertTrue(missingFeedIds.isEmpty, "Feeds with these ids were not found in the \"\(label)\" folder.")
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkArticles(in account: Account, againstItemsInStreamInJSONNamed name: String, subdirectory: String? = nil) {
|
func checkArticles(in account: Account, againstItemsInStreamInJSONNamed name: String, subdirectory: String? = nil) throws {
|
||||||
let stream = testJSON(named: name, subdirectory: subdirectory) as! [String:Any]
|
let stream = testJSON(named: name, subdirectory: subdirectory) as! [String:Any]
|
||||||
checkArticles(in: account, againstItemsInStreamInJSONPayload: stream)
|
try checkArticles(in: account, againstItemsInStreamInJSONPayload: stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkArticles(in account: Account, againstItemsInStreamInJSONPayload stream: [String: Any]) {
|
func checkArticles(in account: Account, againstItemsInStreamInJSONPayload stream: [String: Any]) throws {
|
||||||
checkArticles(in: account, correspondToStreamItemsIn: stream)
|
try checkArticles(in: account, correspondToStreamItemsIn: stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct ArticleItem {
|
private struct ArticleItem {
|
||||||
@ -188,13 +188,13 @@ class FeedlyTestSupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Awkwardly titled to make it clear the JSON given is from a stream response.
|
/// Awkwardly titled to make it clear the JSON given is from a stream response.
|
||||||
func checkArticles(in testAccount: Account, correspondToStreamItemsIn stream: [String: Any]) {
|
func checkArticles(in testAccount: Account, correspondToStreamItemsIn stream: [String: Any]) throws {
|
||||||
|
|
||||||
let items = stream["items"] as! [[String: Any]]
|
let items = stream["items"] as! [[String: Any]]
|
||||||
let articleItems = items.map { ArticleItem(item: $0) }
|
let articleItems = items.map { ArticleItem(item: $0) }
|
||||||
let itemIds = Set(articleItems.map { $0.id })
|
let itemIds = Set(articleItems.map { $0.id })
|
||||||
|
|
||||||
let articles = testAccount.fetchArticles(.articleIDs(itemIds))
|
let articles = try testAccount.fetchArticles(.articleIDs(itemIds))
|
||||||
let articleIds = Set(articles.map { $0.articleID })
|
let articleIds = Set(articles.map { $0.articleID })
|
||||||
|
|
||||||
let missing = itemIds.subtracting(articleIds)
|
let missing = itemIds.subtracting(articleIds)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user