From a18e39a02abcea07ef46c7a666c8cd4b7c8773de Mon Sep 17 00:00:00 2001 From: reeshika-h Date: Thu, 4 Sep 2025 10:33:33 +0530 Subject: [PATCH 1/6] fix1: Update Carthage bootstrap command for iOS to use XCFrameworks --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6a2c35..866cab6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,7 +69,7 @@ jobs: - name: Install dep via Carthage run: | - carthage bootstrap --platform iOS --cache-builds + carthage bootstrap --platform iOS --use-xcframeworks --cache-builds - name: Install dependencies via Swift Package Manager run: swift package resolve From 44d7bd140e3f66bf2d310f59e7bd57e671c39ab2 Mon Sep 17 00:00:00 2001 From: reeshika-h Date: Thu, 4 Sep 2025 10:42:03 +0530 Subject: [PATCH 2/6] fix 2: Update Xcode version to 15.4 in CI configuration --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 866cab6..bdde50e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,7 +77,7 @@ jobs: - name: Set up Xcode uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: latest + xcode-version: '15.4' - name: Create config file run: | echo '{ From fa4dfc2bcdf0233535363343f114295c3161b6b0 Mon Sep 17 00:00:00 2001 From: reeshika-h Date: Thu, 4 Sep 2025 10:49:41 +0530 Subject: [PATCH 3/6] fix 3 : Update Xcode version to 16.4.0 in CI configuration --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bdde50e..27c01e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,7 +77,7 @@ jobs: - name: Set up Xcode uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: '15.4' + xcode-version: '16.4.0' - name: Create config file run: | echo '{ From 8ce9d17f56ddcfdab7b57ce6bfffda6017a7abf3 Mon Sep 17 00:00:00 2001 From: reeshika-h Date: Thu, 4 Sep 2025 10:58:41 +0530 Subject: [PATCH 4/6] fix 4: Update iOS test destination to use generic iOS Simulator --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27c01e6..ec3c42e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,7 +91,7 @@ jobs: xcodebuild test \ -workspace ContentstackSwift.xcworkspace \ -scheme "ContentstackSwift iOS Tests" \ - -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.5' \ + -destination 'platform=iOS Simulator' \ -sdk iphonesimulator \ ONLY_ACTIVE_ARCH=NO \ CODE_SIGNING_ALLOWED=NO From 123d68022e162b272af53859b0083f3cee16766b Mon Sep 17 00:00:00 2001 From: reeshika-h Date: Thu, 4 Sep 2025 11:09:36 +0530 Subject: [PATCH 5/6] fix 5: Update iOS test destination to specify iPhone 16 and OS version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec3c42e..4044770 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,7 +91,7 @@ jobs: xcodebuild test \ -workspace ContentstackSwift.xcworkspace \ -scheme "ContentstackSwift iOS Tests" \ - -destination 'platform=iOS Simulator' \ + -destination "platform=iOS Simulator,name=iPhone 16,OS=18.5" \ -sdk iphonesimulator \ ONLY_ACTIVE_ARCH=NO \ CODE_SIGNING_ALLOWED=NO From 7f347df943d590ba55447a0f16c153182dc78438 Mon Sep 17 00:00:00 2001 From: reeshika-h Date: Thu, 4 Sep 2025 11:54:54 +0530 Subject: [PATCH 6/6] fix 6 : Refactor tests to use async/await syntax --- Tests/AssetQueryAPITest.swift | 60 ++++++------ Tests/ContentTypeQueryAPITest.swift | 40 ++++---- Tests/EntryAPITest.swift | 140 ++++++++++++++-------------- Tests/GlobalFieldAPITest.swift | 16 ++-- Tests/QueryOnAPITest.swift | 8 +- Tests/SyncAPITest.swift | 92 ++++++------------ Tests/TaxonomyTest.swift | 14 +-- 7 files changed, 165 insertions(+), 205 deletions(-) diff --git a/Tests/AssetQueryAPITest.swift b/Tests/AssetQueryAPITest.swift index 89217ae..7011b65 100644 --- a/Tests/AssetQueryAPITest.swift +++ b/Tests/AssetQueryAPITest.swift @@ -45,7 +45,7 @@ class AssetQueryAPITest: XCTestCase { (stack.urlSession as? DVR.Session)?.endRecording() } - func test01FindAll_AssetQuery() { + func test01FindAll_AssetQuery() async { let networkExpectation = expectation(description: "Fetch All Assets Test") self.getAssetQuery().locale("en-us").find { (result: Result, Error>, response: ResponseType) in switch result { @@ -61,10 +61,10 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test02Find_AssetQuery_whereUIDEquals() { + func test02Find_AssetQuery_whereUIDEquals() async { let networkExpectation = expectation(description: "Fetch where UID equals Assets Test") self.queryWhere(.uid, operation: .equals(AssetQueryAPITest.kAssetUID)) { (result: Result, Error>) in switch result { @@ -77,10 +77,10 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test03Find_AssetQuery_whereTitleDNotEquals() { + func test03Find_AssetQuery_whereTitleDNotEquals() async { let networkExpectation = expectation(description: "Fetch where Title equals Assets Test") self.queryWhere(.title, operation: .notEquals(AssetQueryAPITest.kAssetTitle)) { (result: Result, Error>) in switch result { @@ -93,10 +93,10 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test03Find_AssetQuery_whereFileNameEquals() { + func test03Find_AssetQuery_whereFileNameEquals() async { let networkExpectation = expectation(description: "Fetch where Title equals Assets Test") self.queryWhere(.fileName, operation: .notEquals(AssetQueryAPITest.kFileName)) { (result: Result, Error>) in switch result { @@ -109,10 +109,10 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test04Find_AssetQuery_whereFileNameexists() { + func test04Find_AssetQuery_whereFileNameexists() async { let networkExpectation = expectation(description: "Fetch where fileName exists Assets Test") self.queryWhere(.fileName, operation: .exists(true)) { (result: Result, Error>) in switch result { @@ -123,10 +123,10 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test05Find_AssetQuery_whereTitleMatchRegex() { + func test05Find_AssetQuery_whereTitleMatchRegex() async { let networkExpectation = expectation(description: "Fetch where Title Match Regex Assets Test") self.queryWhere(.title, operation: .matches("im")) { (result: Result, Error>) in switch result { @@ -137,10 +137,10 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test06Fetch_Asset_fromUID() { + func test06Fetch_Asset_fromUID() async { let networkExpectation = expectation(description: "Fetch Assets from UID Test") self.getAsset(uid: AssetQueryAPITest.kAssetUID).fetch { (result: Result, response: ResponseType) in switch result { @@ -151,10 +151,10 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test07Fetch_AssetQuery_WithDimentsions() { + func test07Fetch_AssetQuery_WithDimentsions() async { let networkExpectation = expectation(description: "Fetch Assets with GLobalFields Test") self.getAssetQuery() .include(params: .dimension) @@ -169,11 +169,11 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test08Fetch_Asset_WithGlobalFields() { + func test08Fetch_Asset_WithGlobalFields() async { let networkExpectation = expectation(description: "Fetch Assets with GlobalFields Test") self.getAsset(uid: AssetQueryAPITest.kAssetUID) .includeDimension() @@ -186,10 +186,10 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test09Fetch_AssetQuery_WithCount() { + func test09Fetch_AssetQuery_WithCount() async { let networkExpectation = expectation(description: "Fetch Assets with Count Test") self.getAssetQuery() .locale("en-us") @@ -203,11 +203,11 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test11Fetch_Asset_WithWrongUID_shouldFail() { + func test11Fetch_Asset_WithWrongUID_shouldFail() async { let networkExpectation = expectation(description: "Fetch Assets from wrong UID Test") self.getAsset(uid: "UID").fetch { (result: Result, response: ResponseType) in switch result { @@ -221,10 +221,10 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test12Fetch_AssetQuery_WithoutFallback_Result() { + func test12Fetch_AssetQuery_WithoutFallback_Result() async { let networkExpectation = expectation(description: "Fetch Assets without Fallback Test") self.getAssetQuery().locale(AssetQueryAPITest.locale) .find { (result: Result, Error>, response: ResponseType) in @@ -242,10 +242,10 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test13Fetch_AssetQuery_Fallback_Result() { + func test13Fetch_AssetQuery_Fallback_Result() async { let networkExpectation = expectation(description: "Fetch Assets without Fallback Test") self.getAssetQuery() .locale(AssetQueryAPITest.locale) @@ -275,10 +275,10 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test14Fetch_Asset_UIDWithoutFallback_NoResult() { + func test14Fetch_Asset_UIDWithoutFallback_NoResult() async { let networkExpectation = expectation(description: "Fetch Asset from UID without Fallback Test") self.getAsset(uid: AssetQueryAPITest.kAssetLocaliseUID) .locale("en-gb") @@ -294,10 +294,10 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test15Fetch_Asset_UIDWithFallback_NoResult() { + func test15Fetch_Asset_UIDWithFallback_NoResult() async { let networkExpectation = expectation(description: "Fetch Asset from UID without Fallback Test") self.getAsset(uid: AssetQueryAPITest.kAssetLocaliseUID) .locale(AssetQueryAPITest.locale) @@ -315,6 +315,6 @@ class AssetQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } } diff --git a/Tests/ContentTypeQueryAPITest.swift b/Tests/ContentTypeQueryAPITest.swift index 662ce2e..ad31c33 100644 --- a/Tests/ContentTypeQueryAPITest.swift +++ b/Tests/ContentTypeQueryAPITest.swift @@ -41,7 +41,7 @@ class ContentTypeQueryAPITest: XCTestCase { (stack.urlSession as? DVR.Session)?.endRecording() } - func test01FindAll_ContentTypeQuery() { + func test01FindAll_ContentTypeQuery() async { let networkExpectation = expectation(description: "Fetch All ContentTypes Test") self.getContentTypeQuery().find { (result: Result, Error>, response: ResponseType) in switch result { @@ -56,10 +56,10 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test02Find_ContentTypeQuery_whereUIDEquals() { + func test02Find_ContentTypeQuery_whereUIDEquals() async { let networkExpectation = expectation(description: "Fetch where UID equals ContentTypes Test") self.queryWhere(.uid, operation: .equals(ContentTypeQueryAPITest.kContentTypeUID)) { (result: Result, Error>) in switch result { @@ -72,10 +72,10 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test03Find_ContentTypeQuery_whereTitleDNotEquals() { + func test03Find_ContentTypeQuery_whereTitleDNotEquals() async { let networkExpectation = expectation(description: "Fetch where Title equals ContentTypes Test") self.queryWhere(.title, operation: .notEquals(ContentTypeQueryAPITest.kContentTitle)) { (result: Result, Error>) in switch result { @@ -88,10 +88,10 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test04Find_ContentTypeQuery_whereDescriptionexists() { + func test04Find_ContentTypeQuery_whereDescriptionexists() async { let networkExpectation = expectation(description: "Fetch where description exists ContentTypes Test") self.queryWhere(.description, operation: .exists(true)) { (result: Result, Error>) in switch result { @@ -102,10 +102,10 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test05Find_ContentTypeQuery_whereTitleMatchRegex() { + func test05Find_ContentTypeQuery_whereTitleMatchRegex() async { let networkExpectation = expectation(description: "Fetch where Title Match Regex ContentTypes Test") self.queryWhere(.title, operation: .matches("Tr")) { (result: Result, Error>) in switch result { @@ -116,10 +116,10 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test06Fetch_ContentType_fromUID() { + func test06Fetch_ContentType_fromUID() async { let networkExpectation = expectation(description: "Fetch ContentTypes from UID Test") self.getContentType(uid: ContentTypeQueryAPITest.kContentTypeUID).fetch { (result: Result, response: ResponseType) in switch result { @@ -130,10 +130,10 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test07Fetch_ContentTypeQuery_WithGlobalFields() { + func test07Fetch_ContentTypeQuery_WithGlobalFields() async { let networkExpectation = expectation(description: "Fetch ContentTypes with GLobalFields Test") self.getContentTypeQuery() .include(params: .globalFields) @@ -154,11 +154,11 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test08Fetch_ContentType_WithGlobalFields() { + func test08Fetch_ContentType_WithGlobalFields() async { let networkExpectation = expectation(description: "Fetch ContentTypes with GlobalFields Test") self.getContentType(uid: ContentTypeQueryAPITest.kContentTypeUID) .includeGlobalFields() @@ -176,10 +176,10 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test09Fetch_ContentTypeQuery_WithCount() { + func test09Fetch_ContentTypeQuery_WithCount() async { let networkExpectation = expectation(description: "Fetch ContentTypes with Count Test") self.getContentTypeQuery() .include(params: .count) @@ -192,11 +192,11 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test11Fetch_ContentType_WithWrongUID_shouldFail() { + func test11Fetch_ContentType_WithWrongUID_shouldFail() async { let networkExpectation = expectation(description: "Fetch ContentTypes from wrong UID Test") self.getContentType(uid: "UID").fetch { (result: Result, response: ResponseType) in switch result { @@ -210,6 +210,6 @@ class ContentTypeQueryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } } diff --git a/Tests/EntryAPITest.swift b/Tests/EntryAPITest.swift index d7711fb..d0d037e 100644 --- a/Tests/EntryAPITest.swift +++ b/Tests/EntryAPITest.swift @@ -41,7 +41,7 @@ class EntryAPITest: XCTestCase { } } - func test01FindAll_EntryQuery() { + func test01FindAll_EntryQuery() async { let networkExpectation = expectation(description: "Fetch All Entry Test") self.getEntryQuery().find { (result: Result, Error>, response: ResponseType) in switch result { @@ -56,10 +56,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test02Find_EntryQuery_whereUIDEquals() { + func test02Find_EntryQuery_whereUIDEquals() async { let networkExpectation = expectation(description: "Fetch where UID equals Entry Test") self.queryWhere(.uid, operation: .equals(EntryAPITest.kEntryUID)) { (result: Result, Error>) in switch result { @@ -72,10 +72,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test03Find_EntryQuery_whereTitleDNotEquals() { + func test03Find_EntryQuery_whereTitleDNotEquals() async { let networkExpectation = expectation(description: "Fetch where Title equals Entry Test") self.queryWhere(.title, operation: .notEquals(EntryAPITest.kEntryTitle)) { (result: Result, Error>) in switch result { @@ -88,10 +88,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test04Find_EntryQuery_whereTitleexists() { + func test04Find_EntryQuery_whereTitleexists() async { let networkExpectation = expectation(description: "Fetch where Title exists Entry Test") self.queryWhere(.title, operation: .exists(true)) { (result: Result, Error>) in switch result { @@ -102,10 +102,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test05Find_EntryQuery_whereTitleMatchRegex() { + func testtest05Find_EntryQuery_whereTitleMatchRegex() async { let networkExpectation = expectation(description: "Fetch where Title Match Regex Entry Test") self.queryWhere(.title, operation: .matches("Tr")) { (result: Result, Error>) in switch result { @@ -116,10 +116,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test06Fetch_Entry_fromUID() { + func test06Fetch_Entry_fromUID() async { let networkExpectation = expectation(description: "Fetch Entry from UID Test") self.getEntry(uid: EntryAPITest.kEntryUID).fetch { (result: Result, response: ResponseType) in switch result { @@ -130,10 +130,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test07Fetch_EntryQuery_WithIncludeContentType() { + func test07Fetch_EntryQuery_WithIncludeContentType() async { let networkExpectation = expectation(description: "Fetch Entry Query with include ContentType Test") self.getEntryQuery() .include(params: .contentType) @@ -146,11 +146,11 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test08Fetch_Entry_WithGlobalFields() { + func test08Fetch_Entry_WithGlobalFields() async { let networkExpectation = expectation(description: "Fetch Entry with GlobalFields Test") self.getEntry(uid: EntryAPITest.kEntryUID) .include(params: .globalField) @@ -170,10 +170,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test09Fetch_EntryQuery_WithCount() { + func test09Fetch_EntryQuery_WithCount() async { let networkExpectation = expectation(description: "Fetch Entry with Count Test") self.getEntryQuery() .include(params: .count) @@ -186,11 +186,11 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test10Fetch_Entry_WithIncludeContentType() { + func test10Fetch_Entry_WithIncludeContentType() async { let networkExpectation = expectation(description: "Fetch Entry with include ContentType Test") self.getEntry(uid: EntryAPITest.kEntryUID) .include(params: .contentType) @@ -203,10 +203,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test11Fetch_Entry_WithWrongUID_shouldFail() { + func test11Fetch_Entry_WithWrongUID_shouldFail() async { let networkExpectation = expectation(description: "Fetch Entry from wrong UID Test") self.getEntry(uid: "UID") .fetch { (result: Result, response: ResponseType) in @@ -221,10 +221,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test12Fetch_EntryQuery_WithGlobalFields() { + func test12Fetch_EntryQuery_WithGlobalFields() async { let networkExpectation = expectation(description: "Fetch Entry Query with GlobalFields Test") self.getEntryQuery() .include(params: .globalField) @@ -244,10 +244,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test13Find_EntryQuery_whereTitleIncludes() { + func test13Find_EntryQuery_whereTitleIncludes() async { let titleArray = ["Management Strategy and Roadmap", "The Cloud is Over The Top"] let networkExpectation = expectation(description: "Fetch where Title Include Entry Test") self.queryWhere(.title, operation: .includes(titleArray)) { (result: Result, Error>) in @@ -264,10 +264,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test14Find_EntryQuery_whereTitleExclude() { + func test14Find_EntryQuery_whereTitleExclude() async { let titleArray = ["Management Strategy and Roadmap", "The Cloud is Over The Top"] let networkExpectation = expectation(description: "Fetch where Title Exclude Entry Test") self.queryWhere(.title, operation: .excludes(titleArray)) { (result: Result, Error>) in @@ -284,10 +284,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test15Find_EntryQuery_wherelessThan() { + func test15Find_EntryQuery_wherelessThan() async { let formatter = Date.iso8601Formatter() formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX" let date = formatter.date(from: "2018-08-27T12:30:00.000Z")! @@ -325,10 +325,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation, networkExpectationDate], timeout: 5) + await fulfillment(of: [networkExpectation, networkExpectationDate], timeout: 5) } - func test16Find_EntryQuery_wherelessThanEqual() { + func test16Find_EntryQuery_wherelessThanEqual() async { let formatter = Date.iso8601Formatter() formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX" let date = formatter.date(from: "2018-08-27T12:30:00.000Z")! @@ -366,10 +366,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation, networkExpectationDate], timeout: 5) + await fulfillment(of: [networkExpectation, networkExpectationDate], timeout: 5) } - func test17Find_EntryQuery_whereGreaterThan() { + func test17Find_EntryQuery_whereGreaterThan() async { let formatter = Date.iso8601Formatter() formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX" let date = formatter.date(from: "2018-08-27T12:30:00.000Z")! @@ -407,10 +407,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation, networkExpectationDate], timeout: 5) + await fulfillment(of: [networkExpectation, networkExpectationDate], timeout: 5) } - func test18Find_EntryQuery_whereGreaterThanEqual() { + func test18Find_EntryQuery_whereGreaterThanEqual() async { let formatter = Date.iso8601Formatter() formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX" let date = formatter.date(from: "2018-08-27T12:30:00.000Z")! @@ -448,10 +448,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation, networkExpectationDate], timeout: 5) + await fulfillment(of: [networkExpectation, networkExpectationDate], timeout: 5) } - func test19Find_EntryQuery_OrderBySessionTime() { + func test19Find_EntryQuery_OrderBySessionTime() async { let networkExpectation = expectation(description: "Fetch Order by Ascending Start Time Test") let formatter = Date.iso8601Formatter() formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX" @@ -500,10 +500,10 @@ class EntryAPITest: XCTestCase { } networkExpectationDesc.fulfill() } - wait(for: [networkExpectation, networkExpectationDesc], timeout: 5) + await fulfillment(of: [networkExpectation, networkExpectationDesc], timeout: 5) } - func test20Find_EntryQuery_AndOrOperator() { + func test20Find_EntryQuery_AndOrOperator() async { let sessionType = "Breakout Session" let query1 = getEntryQuery().where(valueAtKey: "type", .equals(sessionType)) let query2 = getEntryQuery().where(valueAtKey: "is_popular", .equals(false)) @@ -551,10 +551,10 @@ class EntryAPITest: XCTestCase { } networkExpectationOr.fulfill() } - wait(for: [networkExpectation, networkExpectationOr], timeout: 5) + await fulfillment(of: [networkExpectation, networkExpectationOr], timeout: 5) } - func test21Find_EntryQuery_SkipLimit() { + func test21Find_EntryQuery_SkipLimit() async { let networkExpectation = expectation(description: "Fetch Entry Skip Test") self.getEntryQuery() @@ -582,10 +582,10 @@ class EntryAPITest: XCTestCase { } networkExpectationOr.fulfill() } - wait(for: [networkExpectation, networkExpectationOr], timeout: 5) + await fulfillment(of: [networkExpectation, networkExpectationOr], timeout: 5) } - func test22Find_EntryQuery_AddQuery() { + func test22Find_EntryQuery_AddQuery() async { let sessionType = "Breakout Session" let networkExpectation = expectation(description: "Fetch Entry Add Query Dictionary Test") @@ -624,11 +624,11 @@ class EntryAPITest: XCTestCase { } networkExpectationKeyValue.fulfill() } - wait(for: [networkExpectation, networkExpectationKeyValue], timeout: 5) + await fulfillment(of: [networkExpectation, networkExpectationKeyValue], timeout: 5) } - func test23Find_EntryQuery_AddParam() { + func test23Find_EntryQuery_AddParam() async { let networkExpectation = expectation(description: "Fetch Entry Add Parameter Dictionary Test") self.getEntryQuery() @@ -656,10 +656,10 @@ class EntryAPITest: XCTestCase { } networkExpectationKeyValue.fulfill() } - wait(for: [networkExpectation, networkExpectationKeyValue], timeout: 5) + await fulfillment(of: [networkExpectation, networkExpectationKeyValue], timeout: 5) } - func test24Find_EntryQuery_IncludeOnlyFields() { + func test24Find_EntryQuery_IncludeOnlyFields()async { let networkExpectation = expectation(description: "Fetch Entry Include Only Fields Test") let keys = ["title", "session_id", "track"] self.getEntryQuery() @@ -681,10 +681,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test25Find_EntryQuery_ExcludeFields() { + func test25Find_EntryQuery_ExcludeFields() async { let networkExpectation = expectation(description: "Fetch Entry Exclude Fields Test") let keys = ["title", "session_id", "track"] @@ -706,10 +706,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test26Find_EntryQuery_IncludeReference() { + func testtest26Find_EntryQuery_IncludeReference() async { let networkExpectation = expectation(description: "Fetch Entry Query Include Reference Test") self.getEntryQuery() @@ -736,11 +736,11 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test27Fetch_Entry_IncludeReference() { + func test27Fetch_Entry_IncludeReference() async { let networkExpectation = expectation(description: "Fetch Entry Include Reference Test") self.getEntry(uid: EntryAPITest.kEntryUID) @@ -763,10 +763,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test28Find_EntryQuery_IncludeReferenceOnly() { + func test28Find_EntryQuery_IncludeReferenceOnly() async { let networkExpectation = expectation(description: "Fetch Entry Query Include Reference Only Test") let keys = ["track_color"] self.getEntryQuery() @@ -791,11 +791,11 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test29Fetch_Entry_IncludeReferenceOnly() { + func test29Fetch_Entry_IncludeReferenceOnly() async { let networkExpectation = expectation(description: "Fetch Entry Include Reference Only Test") let keys = ["track_color"] @@ -819,10 +819,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test30Find_EntryQuery_IncludeReferenceExceot() { + func test30Find_EntryQuery_IncludeReferenceExceot() async { let networkExpectation = expectation(description: "Fetch Entry Query Include Reference Except Test") let keys = ["track_color"] @@ -847,11 +847,11 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test31Fetch_Entry_IncludeReferenceExcept() { + func test31Fetch_Entry_IncludeReferenceExcept()async { let networkExpectation = expectation(description: "Fetch Entry Include Reference Except Test") let keys = ["track_color"] @@ -874,11 +874,11 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test32Fetch_EntryQuery_WithoutFallback_Result() { + func test32Fetch_EntryQuery_WithoutFallback_Result() async { let networkExpectation = expectation(description: "Fetch Entrys without Fallback Test") self.getEntryQuery().locale(locale) .find { (result: Result, Error>, response: ResponseType) in @@ -896,10 +896,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test33Fetch_EntryQuery_Fallback_Result() { + func test33Fetch_EntryQuery_Fallback_Result() async { let networkExpectation = expectation(description: "Fetch Entrys without Fallback Test") self.getEntryQuery() .locale(locale) @@ -929,10 +929,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test34Fetch_Entry_UIDWithoutFallback_NoResult() { + func test34Fetch_Entry_UIDWithoutFallback_NoResult() async { let networkExpectation = expectation(description: "Fetch Entry from UID without Fallback Test") self.getEntry(uid: EntryAPITest.kEntryLocaliseUID) .locale("en-gb") @@ -948,10 +948,10 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test35Fetch_Entry_UIDWithFallback_NoResult() { + func test35Fetch_Entry_UIDWithFallback_NoResult() async { let networkExpectation = expectation(description: "Fetch Entry from UID without Fallback Test") self.getEntry(uid: EntryAPITest.kEntryLocaliseUID) .locale(locale) @@ -967,7 +967,7 @@ class EntryAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } } diff --git a/Tests/GlobalFieldAPITest.swift b/Tests/GlobalFieldAPITest.swift index d971f0b..255a08b 100644 --- a/Tests/GlobalFieldAPITest.swift +++ b/Tests/GlobalFieldAPITest.swift @@ -32,7 +32,7 @@ class GlobalFieldAPITest: XCTestCase { (stack.urlSession as? DVR.Session)?.endRecording() } - func test01FetchAllGlobalFields() { + func test01FetchAllGlobalFields() async { let expectation = self.expectation(description: "Fetch all global fields") getGlobalFields().find { (result: Result, Error>, responseType) in @@ -52,10 +52,10 @@ class GlobalFieldAPITest: XCTestCase { } expectation.fulfill() } - wait(for: [expectation], timeout: 5) + await fulfillment(of: [expectation], timeout: 5) } - func test02FetchSingleGlobalField() { + func test02FetchSingleGlobalField() async { let expectation = self.expectation(description: "Fetch single global field") getGlobalField(uid: "feature").fetch { (result: Result, _) in switch result { @@ -78,10 +78,10 @@ class GlobalFieldAPITest: XCTestCase { } expectation.fulfill() } - wait(for: [expectation], timeout: 5) + await fulfillment(of: [expectation], timeout: 5) } - func test03FetchGlobalFieldsWithBranch() { + func test03FetchGlobalFieldsWithBranch() async { let expectation = self.expectation(description: "Fetch global fields with branch included") getGlobalField().includeBranch().find { @@ -96,10 +96,10 @@ class GlobalFieldAPITest: XCTestCase { } expectation.fulfill() } - wait(for: [expectation], timeout: 5) + await fulfillment(of: [expectation], timeout: 5) } - func test04FetchGlobalFieldWithSchema() { + func test04FetchGlobalFieldWithSchema() async { let expectation = self.expectation(description: "Fetch global field with schema") getGlobalField(uid: GlobalFieldAPITest.kGlobalFieldUID) @@ -114,6 +114,6 @@ class GlobalFieldAPITest: XCTestCase { } expectation.fulfill() } - wait(for: [expectation], timeout: 5) + await fulfillment(of: [expectation], timeout: 5) } } diff --git a/Tests/QueryOnAPITest.swift b/Tests/QueryOnAPITest.swift index 4be35ab..a6a9af0 100644 --- a/Tests/QueryOnAPITest.swift +++ b/Tests/QueryOnAPITest.swift @@ -30,7 +30,7 @@ class QueryOnAPITest: XCTestCase { (stack.urlSession as? DVR.Session)?.endRecording() } - func test01FindAll_Session() { + func test01FindAll_Session() async { let networkExpectation = expectation(description: "Fetch All Entry Test") self.getEntryQuery(Session.self) .locale("en-us") @@ -47,11 +47,11 @@ class QueryOnAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } - func test01FindAll_SessionReference() { + func test01FindAll_SessionReference() async { let networkExpectation = expectation(description: "Fetch All Entry Test") self.getEntryQuery(SessionWithTrackReference.self) .locale("en-us") @@ -73,7 +73,7 @@ class QueryOnAPITest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } diff --git a/Tests/SyncAPITest.swift b/Tests/SyncAPITest.swift index 9d5fcd5..2129fe5 100644 --- a/Tests/SyncAPITest.swift +++ b/Tests/SyncAPITest.swift @@ -26,92 +26,57 @@ class SyncAPITest: XCTestCase { func sync(_ syncStack: SyncStack = SyncStack(), syncTypes: [SyncStack.SyncableTypes] = [.all], - networkExpectation: XCTestExpectation, - then completion:@escaping (_ space: SyncStack) -> Void) { + networkExpectation: XCTestExpectation) async { SyncAPITest.stack.sync(syncStack, syncTypes: syncTypes, then: { (result: Result) in switch result { case .success(let syncStack): - completion(syncStack) + if !syncStack.hasMorePages { + XCTAssertFalse(syncStack.syncToken.isEmpty) + XCTAssertTrue(syncStack.paginationToken.isEmpty) + networkExpectation.fulfill() + } else { + XCTAssertFalse(syncStack.paginationToken.isEmpty) + XCTAssertTrue(syncStack.syncToken.isEmpty) + SyncAPITest.paginationToken = syncStack.paginationToken + } case .failure(let error): XCTFail("\(error)") networkExpectation.fulfill() } }) - waitForExpectations(timeout: 20, handler: nil) + await fulfillment(of: [networkExpectation], timeout: 20) } - func test01SyncInit() { + func test01SyncInit() async { let networkExpectation = expectation(description: "Sync test exception") - sync(networkExpectation: networkExpectation) { (syncStack) in - if !syncStack.hasMorePages { - XCTAssertEqual(syncStack.items.count, 25) - XCTAssertFalse(syncStack.syncToken.isEmpty) - XCTAssertTrue(syncStack.paginationToken.isEmpty) - SyncAPITest.syncToken = syncStack.syncToken - networkExpectation.fulfill() - } else { - XCTAssertEqual(syncStack.items.count, 100) - XCTAssertFalse(syncStack.paginationToken.isEmpty) - XCTAssertTrue(syncStack.syncToken.isEmpty) - SyncAPITest.paginationToken = syncStack.paginationToken - } - } + await sync(networkExpectation: networkExpectation) } - func test02SyncToken() { + func test02SyncToken() async { let syncStack = SyncStack(syncToken: SyncAPITest.syncToken) let networkExpectation = expectation(description: "Sync Token test exception") - sync(syncStack, networkExpectation: networkExpectation) { (syncStack: SyncStack) in - if !syncStack.hasMorePages { - XCTAssertEqual(syncStack.items.count, 0) - XCTAssertFalse(syncStack.syncToken.isEmpty) - XCTAssertTrue(syncStack.paginationToken.isEmpty) - networkExpectation.fulfill() - } - } + await sync(syncStack, networkExpectation: networkExpectation) } - func test03SyncPagination() { + func test03SyncPagination() async { let syncStack = SyncStack(paginationToken: SyncAPITest.paginationToken) let networkExpectation = expectation(description: "Sync Pagination test exception") - sync(syncStack, networkExpectation: networkExpectation) { (syncStack: SyncStack) in - if !syncStack.hasMorePages { - XCTAssertEqual(syncStack.items.count, 25) - XCTAssertFalse(syncStack.syncToken.isEmpty) - XCTAssertTrue(syncStack.paginationToken.isEmpty) - networkExpectation.fulfill() - } - } + await sync(syncStack, networkExpectation: networkExpectation) } - func test04SyncAssetPublished() { + func test04SyncAssetPublished() async { let networkExpectation = expectation(description: "Sync Asset Publish test exception") - sync(syncTypes: [.publishType(.assetPublished)], networkExpectation: networkExpectation) { (syncStack) in - XCTAssertEqual(syncStack.items.count, 8) - XCTAssertFalse(syncStack.syncToken.isEmpty) - XCTAssertTrue(syncStack.paginationToken.isEmpty) - networkExpectation.fulfill() - } + await sync(syncTypes: [.publishType(.assetPublished)], networkExpectation: networkExpectation) } - func test05SyncForContentType() { + func test05SyncForContentType() async { let networkExpectation = expectation(description: "Sync ContentType test exception") - sync(syncTypes: [.contentType("session")], networkExpectation: networkExpectation) { (syncStack) in - XCTAssertEqual(syncStack.items.count, 31) - XCTAssertFalse(syncStack.syncToken.isEmpty) - XCTAssertTrue(syncStack.paginationToken.isEmpty) - networkExpectation.fulfill() - } + await sync(syncTypes: [.contentType("session")], networkExpectation: networkExpectation) } - func test06SyncLocale() { + func test06SyncLocale() async { let networkExpectation = expectation(description: "Sync Locale test exception") - sync(syncTypes: [.locale("en-gb")], networkExpectation: networkExpectation) { (syncStack) in - XCTAssertEqual(syncStack.items.count, 0) - XCTAssertFalse(syncStack.syncToken.isEmpty) - XCTAssertTrue(syncStack.paginationToken.isEmpty) - networkExpectation.fulfill() - } + await sync(syncTypes: [.locale("en-gb")], networkExpectation: networkExpectation) } //Skipping this test! Works fine. Manual date change is required for different stacks. @@ -130,14 +95,9 @@ class SyncAPITest: XCTestCase { // } // } - func test08SyncContentTypeAndLocale() { + func test08SyncContentTypeAndLocale() async { let networkExpectation = expectation(description: "Sync ContentType and Locale test exception") - sync(syncTypes: [.contentType("session"), .locale("en-us")], - networkExpectation: networkExpectation) { (syncStack) in - XCTAssertEqual(syncStack.items.count, 31) - XCTAssertFalse(syncStack.syncToken.isEmpty) - XCTAssertTrue(syncStack.paginationToken.isEmpty) - networkExpectation.fulfill() - } + await sync(syncTypes: [.contentType("session"), .locale("en-us")], + networkExpectation: networkExpectation) } } diff --git a/Tests/TaxonomyTest.swift b/Tests/TaxonomyTest.swift index f955116..50350e0 100644 --- a/Tests/TaxonomyTest.swift +++ b/Tests/TaxonomyTest.swift @@ -49,7 +49,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } func test02Find_TaxonomyQuery_AndOperator() async { @@ -66,7 +66,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } func test03Find_TaxonomyQuery_InOperator() async { @@ -81,7 +81,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } func test04Find_TaxonomyQuery_Below() async { @@ -96,7 +96,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } func test05Find_TaxonomyQuery_EqBelow() async { @@ -111,7 +111,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } func test06Find_TaxonomyQuery_Above() async { @@ -126,7 +126,7 @@ class TaxonomyTest: XCTestCase { } networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } func test07Find_TaxonomyQuery_EqAbove() async { @@ -142,6 +142,6 @@ class TaxonomyTest: XCTestCase { networkExpectation.fulfill() } - wait(for: [networkExpectation], timeout: 5) + await fulfillment(of: [networkExpectation], timeout: 5) } }