This commit is contained in:
Maurice Parker 2019-10-15 19:52:12 -05:00
commit d16cc88577
5 changed files with 35 additions and 21 deletions

View File

@ -121,6 +121,7 @@
9EE4CCFA234F106600FBAE4B /* FeedlyFeedContainerValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EE4CCF9234F106600FBAE4B /* FeedlyFeedContainerValidator.swift */; };
9EEEF71F23545CB4009E9D80 /* FeedlySendArticleStatusesOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEEF71E23545CB4009E9D80 /* FeedlySendArticleStatusesOperation.swift */; };
9EEEF7212355277F009E9D80 /* FeedlySyncStarredArticlesOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEEF7202355277F009E9D80 /* FeedlySyncStarredArticlesOperation.swift */; };
9EEEF75223567CA6009E9D80 /* saved_initial.json in Resources */ = {isa = PBXBuildFile; fileRef = 9EEEF75123567CA6009E9D80 /* saved_initial.json */; };
9EF35F7A234E830E003AE2AE /* FeedlyCompoundOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EF35F79234E830E003AE2AE /* FeedlyCompoundOperation.swift */; };
/* End PBXBuildFile section */
@ -301,6 +302,7 @@
9EE4CCF9234F106600FBAE4B /* FeedlyFeedContainerValidator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedlyFeedContainerValidator.swift; sourceTree = "<group>"; };
9EEEF71E23545CB4009E9D80 /* FeedlySendArticleStatusesOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedlySendArticleStatusesOperation.swift; sourceTree = "<group>"; };
9EEEF7202355277F009E9D80 /* FeedlySyncStarredArticlesOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedlySyncStarredArticlesOperation.swift; sourceTree = "<group>"; };
9EEEF75123567CA6009E9D80 /* saved_initial.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = saved_initial.json; sourceTree = "<group>"; };
9EF35F79234E830E003AE2AE /* FeedlyCompoundOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedlyCompoundOperation.swift; sourceTree = "<group>"; };
D511EEB5202422BB00712EC3 /* Account_project_debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Account_project_debug.xcconfig; sourceTree = "<group>"; };
D511EEB6202422BB00712EC3 /* Account_target.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Account_target.xcconfig; sourceTree = "<group>"; };
@ -523,6 +525,7 @@
9E7F150B2341F2A700F860D1 /* Initial */ = {
isa = PBXGroup;
children = (
9EEEF75123567CA6009E9D80 /* saved_initial.json */,
9E7F15092341EF5A00F860D1 /* feedly_collections_initial.json */,
9E7F150C2341F32000F860D1 /* macintosh_initial.json */,
9E7F15162341F48900F860D1 /* mustread_initial.json */,
@ -780,6 +783,7 @@
51D5875C227F630B00900287 /* tags_initial.json in Resources */,
51D5875A227F630B00900287 /* tags_delete.json in Resources */,
5165D71722821C2400D9D53D /* taggings_add.json in Resources */,
9EEEF75223567CA6009E9D80 /* saved_initial.json in Resources */,
9E832B23234416B400D83249 /* feedly_collections_addfeed.json in Resources */,
5165D71622821C2400D9D53D /* taggings_delete.json in Resources */,
9E7F15112341F39A00F860D1 /* uncategorized_initial.json in Resources */,

View File

@ -20,9 +20,9 @@ class AccountFeedSyncTest: XCTestCase {
func testDownloadSync() {
let testTransport = TestTransport()
testTransport.testFiles["https://api.feedbin.com/v2/tags.json"] = "tags_add.json"
testTransport.testFiles["https://api.feedbin.com/v2/subscriptions.json"] = "subscriptions_initial.json"
testTransport.testFiles["https://api.feedbin.com/v2/icons.json"] = "icons.json"
testTransport.testFiles["tags.json"] = "tags_add.json"
testTransport.testFiles["subscriptions.json"] = "subscriptions_initial.json"
testTransport.testFiles["icons.json"] = "icons.json"
let account = TestAccountManager.shared.createAccount(type: .feedbin, transport: testTransport)
// Test initial folders
@ -52,9 +52,9 @@ class AccountFeedSyncTest: XCTestCase {
XCTAssertEqual(225, account.flattenedFeeds().count)
let bPixels = account.idToFeedDictionary["1096623"]
XCTAssertEqual("Beautiful Pixels", bPixels!.name)
XCTAssertEqual("https://feedpress.me/beautifulpixels", bPixels!.url)
XCTAssertEqual("https://beautifulpixels.com/", bPixels!.homePageURL)
XCTAssertEqual("Beautiful Pixels", bPixels?.name)
XCTAssertEqual("https://feedpress.me/beautifulpixels", bPixels?.url)
XCTAssertEqual("https://beautifulpixels.com/", bPixels?.homePageURL)
XCTAssertEqual("https://favicons.feedbinusercontent.com/ea0/ea010c658d6e356e49ab239b793dc415af707b05.png", bPixels?.faviconURL)
TestAccountManager.shared.deleteAccount(account)

View File

@ -148,6 +148,8 @@ class AccountFeedlySyncTest: XCTestCase {
account.refreshAll() { _ in
preparationExpectation.fulfill()
}
// If there's a failure here, then an operation hasn't completed.
// Check that test files have responses for all the requests this might make.
waitForExpectations(timeout: 5)
}
@ -282,18 +284,17 @@ class AccountFeedlySyncTest: XCTestCase {
func set(testFiles: TestFiles, with transport: TestTransport) {
// TestTransport blacklists certain query items to make mocking responses easier.
let endpoint = "https://sandbox7.feedly.com/v3"
let category = "\(endpoint)/streams/contents?streamId=user/f2f031bd-f3e3-4893-a447-467a291c6d1e/category"
let collectionsEndpoint = "/v3/collections"
switch testFiles {
case .initial:
let dict = [
"\(endpoint)/collections": "feedly_collections_initial.json",
"\(category)/5ca4d61d-e55d-4999-a8d1-c3b9d8789815": "macintosh_initial.json",
"\(category)/global.must": "mustread_initial.json",
"\(category)/885f2e01-d314-4e63-abac-17dcb063f5b5": "programming_initial.json",
"\(category)/66132046-6f14-488d-b590-8e93422723c8": "uncategorized_initial.json",
"\(category)/e31b3fcb-27f6-4f3e-b96c-53902586e366": "weblogs_initial.json",
"/global.saved": "saved_initial.json",
collectionsEndpoint: "feedly_collections_initial.json",
"/5ca4d61d-e55d-4999-a8d1-c3b9d8789815": "macintosh_initial.json",
"/global.must": "mustread_initial.json",
"/885f2e01-d314-4e63-abac-17dcb063f5b5": "programming_initial.json",
"/66132046-6f14-488d-b590-8e93422723c8": "uncategorized_initial.json",
"/e31b3fcb-27f6-4f3e-b96c-53902586e366": "weblogs_initial.json",
]
transport.testFiles = dict
@ -301,16 +302,16 @@ class AccountFeedlySyncTest: XCTestCase {
set(testFiles: .initial, with: transport)
var dict = transport.testFiles
dict["\(endpoint)/collections"] = "feedly_collections_addcollection.json"
dict["\(category)/fc09f383-5a9a-4daa-a575-3efc1733b173"] = "newcollection_addcollection.json"
dict[collectionsEndpoint] = "feedly_collections_addcollection.json"
dict["/fc09f383-5a9a-4daa-a575-3efc1733b173"] = "newcollection_addcollection.json"
transport.testFiles = dict
case .addFeed:
set(testFiles: .addCollection, with: transport)
var dict = transport.testFiles
dict["\(endpoint)/collections"] = "feedly_collections_addfeed.json"
dict["\(category)/global.must"] = "mustread_addfeed.json"
dict[collectionsEndpoint] = "feedly_collections_addfeed.json"
dict["/global.must"] = "mustread_addfeed.json"
transport.testFiles = dict
case .removeFeed:

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,7 @@
import Foundation
import RSWeb
import XCTest
final class TestTransport: Transport {
@ -50,13 +51,20 @@ final class TestTransport: Transport {
let response = httpResponse(for: request, statusCode: testStatusCodes[urlString] ?? 200)
if let testFileName = testFiles[urlString] {
var mockResponseFound = false
for (key, testFileName) in testFiles where urlString.contains(key) {
let testFileURL = Bundle(for: TestTransport.self).resourceURL!.appendingPathComponent(testFileName)
let data = try! Data(contentsOf: testFileURL)
DispatchQueue.global(qos: .background).async {
completion(.success((response, data)))
}
} else {
mockResponseFound = true
break
}
if !mockResponseFound {
// XCTFail("Missing mock response for: \(urlString)")
print("***\nWARNING: \(self) missing mock response for:\n\(urlString)\n***")
DispatchQueue.global(qos: .background).async {
completion(.success((response, nil)))
}