From 8c7361951e87089be46fdc2a0588abae5a1e101c Mon Sep 17 00:00:00 2001 From: Di Wu Date: Thu, 11 Jan 2024 14:02:16 -0800 Subject: [PATCH] add availablility with filter version --- .../Core/DataStoreCategoryConfigurationTests.swift | 3 ++- .../CategoryTests/API/APICategoryClientGraphQLTests.swift | 4 ++-- .../CategoryTests/API/APICategoryConfigurationTests.swift | 3 ++- .../Analytics/AnalyticsCategoryConfigurationTests.swift | 3 ++- .../CategoryTests/Auth/AuthCategoryConfigurationTests.swift | 3 ++- .../DataStore/DataStoreCategoryClientAPITests.swift | 3 ++- .../CategoryTests/DataStore/Model/ListPaginationTests.swift | 3 ++- AmplifyTests/CategoryTests/DataStore/Model/ListTests.swift | 2 ++ .../CategoryTests/DataStore/ModelFieldAssociationTests.swift | 2 ++ AmplifyTests/CategoryTests/DataStore/TemporalTests.swift | 2 +- .../CategoryTests/Geo/GeoCategoryConfigurationTests.swift | 4 +++- .../CategoryTests/Hub/AmplifyOperationHubTests.swift | 3 ++- .../DefaultHubPluginConcurrencyTests.swift | 3 ++- .../DefaultHubPluginCustomChannelTests.swift | 3 ++- .../Hub/DefaultPluginTests/DefaultHubPluginTests.swift | 5 +++-- .../CategoryTests/Hub/HubCategoryConfigurationTests.swift | 4 ++-- .../Logging/LoggingCategoryConfigurationTests.swift | 2 ++ 17 files changed, 35 insertions(+), 17 deletions(-) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/DataStoreCategoryConfigurationTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/DataStoreCategoryConfigurationTests.swift index 490c453cfd..e6c21d3ef3 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/DataStoreCategoryConfigurationTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Core/DataStoreCategoryConfigurationTests.swift @@ -4,7 +4,7 @@ // // SPDX-License-Identifier: Apache-2.0 // - +#if swift(>=5.8) import XCTest @testable import Amplify import AWSDataStorePlugin @@ -41,3 +41,4 @@ class AWSDataStorePluginConfigurationTests: XCTestCase { } } +#endif diff --git a/AmplifyTests/CategoryTests/API/APICategoryClientGraphQLTests.swift b/AmplifyTests/CategoryTests/API/APICategoryClientGraphQLTests.swift index 09a85d35ab..1377986d39 100644 --- a/AmplifyTests/CategoryTests/API/APICategoryClientGraphQLTests.swift +++ b/AmplifyTests/CategoryTests/API/APICategoryClientGraphQLTests.swift @@ -24,7 +24,7 @@ class APICategoryClientGraphQLTests: XCTestCase { mockAmplifyConfig = AmplifyConfiguration(api: apiConfig) } - +#if swift(>=5.8) func testQuery() async throws { let plugin = try makeAndAddMockPlugin() let methodWasInvokedOnPlugin = expectation(description: "method was invoked on plugin") @@ -64,7 +64,7 @@ class APICategoryClientGraphQLTests: XCTestCase { await fulfillment(of: [mutateCompleted], timeout: 0.5) await fulfillment(of: [methodWasInvokedOnPlugin], timeout: 0.5) } - +#endif // MARK: - Utilities func makeAndAddMockPlugin() throws -> MockAPICategoryPlugin { diff --git a/AmplifyTests/CategoryTests/API/APICategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/API/APICategoryConfigurationTests.swift index c15801e609..fb96eecc8e 100644 --- a/AmplifyTests/CategoryTests/API/APICategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/API/APICategoryConfigurationTests.swift @@ -35,7 +35,7 @@ class APICategoryConfigurationTests: XCTestCase { XCTAssertNotNil(Amplify.API) XCTAssertNotNil(try Amplify.API.getPlugin(for: "MockAPICategoryPlugin")) } - +#if swift(>=5.8) func testCanResetAPIPlugin() async throws { let plugin = MockAPICategoryPlugin() let resetWasInvoked = expectation(description: "reset() was invoked") @@ -374,4 +374,5 @@ class APICategoryConfigurationTests: XCTestCase { } } +#endif } diff --git a/AmplifyTests/CategoryTests/Analytics/AnalyticsCategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/Analytics/AnalyticsCategoryConfigurationTests.swift index 9e1b04cb7a..64c8791e0a 100644 --- a/AmplifyTests/CategoryTests/Analytics/AnalyticsCategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/Analytics/AnalyticsCategoryConfigurationTests.swift @@ -35,7 +35,7 @@ class AnalyticsCategoryConfigurationTests: XCTestCase { XCTAssertNotNil(Amplify.Analytics) XCTAssertNotNil(try Amplify.Analytics.getPlugin(for: "MockAnalyticsCategoryPlugin")) } - +#if (swift(>=5.8)) func testCanResetAnalyticsPlugin() async throws { let plugin = MockAnalyticsCategoryPlugin() let resetWasInvoked = expectation(description: "reset() was invoked") @@ -317,4 +317,5 @@ class AnalyticsCategoryConfigurationTests: XCTestCase { } } +#endif } diff --git a/AmplifyTests/CategoryTests/Auth/AuthCategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/Auth/AuthCategoryConfigurationTests.swift index f9c3b38696..7ac2cc2c78 100644 --- a/AmplifyTests/CategoryTests/Auth/AuthCategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/Auth/AuthCategoryConfigurationTests.swift @@ -52,7 +52,7 @@ class AuthCategoryConfigurationTests: XCTestCase { XCTAssertNotNil(Amplify.Auth) XCTAssertNotNil(try Amplify.Auth.getPlugin(for: "MockAuthCategoryPlugin")) } - +#if swift(>=5.8) /// Test if resetting Auth category works /// /// - Given: Amplify framework configured with Auth plugin @@ -435,4 +435,5 @@ class AuthCategoryConfigurationTests: XCTestCase { } } +#endif } diff --git a/AmplifyTests/CategoryTests/DataStore/DataStoreCategoryClientAPITests.swift b/AmplifyTests/CategoryTests/DataStore/DataStoreCategoryClientAPITests.swift index 5a7ad073b2..24eceb22cc 100644 --- a/AmplifyTests/CategoryTests/DataStore/DataStoreCategoryClientAPITests.swift +++ b/AmplifyTests/CategoryTests/DataStore/DataStoreCategoryClientAPITests.swift @@ -4,7 +4,7 @@ // // SPDX-License-Identifier: Apache-2.0 // - +#if swift(>=5.8) import XCTest @testable import Amplify @testable import AmplifyTestCommon @@ -59,3 +59,4 @@ class TestModel: Model { self.id = id } } +#endif diff --git a/AmplifyTests/CategoryTests/DataStore/Model/ListPaginationTests.swift b/AmplifyTests/CategoryTests/DataStore/Model/ListPaginationTests.swift index 83215fc64e..d6fcfe48ca 100644 --- a/AmplifyTests/CategoryTests/DataStore/Model/ListPaginationTests.swift +++ b/AmplifyTests/CategoryTests/DataStore/Model/ListPaginationTests.swift @@ -4,7 +4,7 @@ // // SPDX-License-Identifier: Apache-2.0 // - +#if swift(>=5.8) import XCTest @testable import Amplify @@ -142,3 +142,4 @@ extension ListTests { await fulfillment(of: [getNextPageSuccess], timeout: 1.0) } } +#endif diff --git a/AmplifyTests/CategoryTests/DataStore/Model/ListTests.swift b/AmplifyTests/CategoryTests/DataStore/Model/ListTests.swift index 26cefa0422..6a7bf160a0 100644 --- a/AmplifyTests/CategoryTests/DataStore/Model/ListTests.swift +++ b/AmplifyTests/CategoryTests/DataStore/Model/ListTests.swift @@ -5,6 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#if swift(>=5.8) import XCTest @testable import Amplify @@ -255,3 +256,4 @@ class ListTests: XCTestCase { return try decoder.decode(List.self, from: data) } } +#endif diff --git a/AmplifyTests/CategoryTests/DataStore/ModelFieldAssociationTests.swift b/AmplifyTests/CategoryTests/DataStore/ModelFieldAssociationTests.swift index 40efdd348c..e1a911b116 100644 --- a/AmplifyTests/CategoryTests/DataStore/ModelFieldAssociationTests.swift +++ b/AmplifyTests/CategoryTests/DataStore/ModelFieldAssociationTests.swift @@ -5,6 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#if swift(>=5.8) import XCTest @testable import Amplify @testable import AmplifyTestCommon @@ -103,3 +104,4 @@ class ModelFieldAssociationTests: XCTestCase { } } +#endif diff --git a/AmplifyTests/CategoryTests/DataStore/TemporalTests.swift b/AmplifyTests/CategoryTests/DataStore/TemporalTests.swift index 914cd6ee24..8f535e6711 100644 --- a/AmplifyTests/CategoryTests/DataStore/TemporalTests.swift +++ b/AmplifyTests/CategoryTests/DataStore/TemporalTests.swift @@ -69,7 +69,7 @@ class TemporalTests: XCTestCase { XCTAssertEqual(datetime6.iso8601String, "2023-11-30T11:04:24.000-08:00") let datetime7 = try Temporal.DateTime(iso8601String: "2023-11-30T14:09:27.128Z") XCTAssertEqual(datetime7.iso8601String, "2023-11-30T14:09:27.128Z") - if #available(iOS 15.0, tvOS 15.0, *) { + if #available(iOS 15.0, tvOS 15.0, macOS 12.0, *) { let now = Date.now let dateFormatter = DateFormatter() dateFormatter.timeZone = .init(abbreviation: "HKT") diff --git a/AmplifyTests/CategoryTests/Geo/GeoCategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/Geo/GeoCategoryConfigurationTests.swift index 7233623ffc..d335bb7793 100644 --- a/AmplifyTests/CategoryTests/Geo/GeoCategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/Geo/GeoCategoryConfigurationTests.swift @@ -36,6 +36,7 @@ class GeoCategoryConfigurationTests: XCTestCase { XCTAssertNotNil(try Amplify.Geo.getPlugin(for: "MockGeoCategoryPlugin")) } +#if swift(>=5.8) func testCanResetGeoPlugin() async throws { let plugin = MockGeoCategoryPlugin() let resetWasInvoked = expectation(description: "reset() was invoked") @@ -56,7 +57,8 @@ class GeoCategoryConfigurationTests: XCTestCase { await Amplify.reset() await fulfillment(of: [resetWasInvoked], timeout: 1.0) } - +#endif + func testResetRemovesAddedPlugin() async throws { let plugin = MockGeoCategoryPlugin() try Amplify.add(plugin: plugin) diff --git a/AmplifyTests/CategoryTests/Hub/AmplifyOperationHubTests.swift b/AmplifyTests/CategoryTests/Hub/AmplifyOperationHubTests.swift index baa6629239..4d32eb42f0 100644 --- a/AmplifyTests/CategoryTests/Hub/AmplifyOperationHubTests.swift +++ b/AmplifyTests/CategoryTests/Hub/AmplifyOperationHubTests.swift @@ -32,6 +32,7 @@ class AmplifyOperationHubTests: XCTestCase { /// Given: An AmplifyOperation /// When: I invoke Hub.listen(to: operation) /// Then: I am notified of events for that operation, in the operation event listener format +#if swift(>=5.8) func testlistenerViaListenToOperation() async throws { let options = StorageListRequest.Options(pluginOptions: ["pluginDelay": 0.5]) let request = StorageListRequest(options: options) @@ -50,7 +51,7 @@ class AmplifyOperationHubTests: XCTestCase { await fulfillment(of: [listenerWasInvoked], timeout: 1.0) } - +#endif /// Given: A configured system /// When: I perform an operation with an `listener` listener /// Then: That listener is notified when an event occurs diff --git a/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginConcurrencyTests.swift b/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginConcurrencyTests.swift index 0f8284a3d5..c4b887af44 100644 --- a/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginConcurrencyTests.swift +++ b/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginConcurrencyTests.swift @@ -38,6 +38,7 @@ class DefaultHubPluginConcurrencyTests: XCTestCase { /// - ...to multiple channels /// - ...to multiple subscribers /// Then: All messages are delivered, to the correct listeners +#if swift(>=5.8) func testConcurrentMessageDelivery() async throws { let channelCount = 10 let listenersPerChannel = 50 @@ -81,5 +82,5 @@ class DefaultHubPluginConcurrencyTests: XCTestCase { await fulfillment(of: messagesReceived, timeout: 5.0) } - +#endif } diff --git a/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginCustomChannelTests.swift b/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginCustomChannelTests.swift index 0e7e0892f5..511aea5f99 100644 --- a/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginCustomChannelTests.swift +++ b/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginCustomChannelTests.swift @@ -37,6 +37,7 @@ class DefaultHubPluginCustomChannelTests: XCTestCase { /// Given: A listener to a custom channel /// When: A message is dispatched to that custom channel /// Then: The listener is invoked +#if swift(>=5.8) func testMessageReceivedOnCustomChannel() async throws { let eventReceived = expectation(description: "Event received") @@ -104,5 +105,5 @@ class DefaultHubPluginCustomChannelTests: XCTestCase { await fulfillment(of: [listener1Invoked, listener2Invoked], timeout: 0.5) } - +#endif } diff --git a/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginTests.swift b/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginTests.swift index e6a3bf08ab..e99c9afea8 100644 --- a/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginTests.swift +++ b/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginTests.swift @@ -57,6 +57,7 @@ class DefaultHubPluginTests: XCTestCase { /// Given: The default Hub plugin /// When: I invoke listen(to:eventName:) /// Then: I receive messages with that event name +#if swift(>=5.8) func testDefaultPluginListenEventName() async throws { let expectedMessageReceived = expectation(description: "Message was received as expected") let unsubscribeToken = plugin.listen(to: .storage, eventName: "TEST_EVENT") { _ in @@ -74,7 +75,7 @@ class DefaultHubPluginTests: XCTestCase { /// Given: The default Hub plugin with a registered listener /// When: I dispatch a message - /// Then: My listener is invoked with the message + /// Then: My listener is invoked with the func testDefaultPluginDispatches() async throws { let messageReceived = expectation(description: "Message was received") @@ -149,7 +150,7 @@ class DefaultHubPluginTests: XCTestCase { plugin.dispatch(to: .storage, payload: HubPayload(eventName: "TEST_EVENT")) await fulfillment(of: [try XCTUnwrap(currentExpectation)], timeout: 0.5) } - +#endif /// Given: The default Hub plugin /// When: I invoke listen() for a specified channel and subsequently dispatch a message to a different channel /// Then: My listener is not invoked diff --git a/AmplifyTests/CategoryTests/Hub/HubCategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/Hub/HubCategoryConfigurationTests.swift index a2d8f2d903..cc3d73dd1f 100644 --- a/AmplifyTests/CategoryTests/Hub/HubCategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/Hub/HubCategoryConfigurationTests.swift @@ -35,7 +35,7 @@ class HubCategoryConfigurationTests: XCTestCase { XCTAssertNotNil(Amplify.Hub) XCTAssertNotNil(try Amplify.Hub.getPlugin(for: "MockHubCategoryPlugin")) } - +#if swift(>=5.8) func testCanResetHubPlugin() async throws { let plugin = MockHubCategoryPlugin() let resetWasInvoked = expectation(description: "reset() was invoked") @@ -56,7 +56,7 @@ class HubCategoryConfigurationTests: XCTestCase { await Amplify.reset() await fulfillment(of: [resetWasInvoked], timeout: 1.0) } - +#endif func testResetRemovesAddedPlugin() async throws { let plugin = MockHubCategoryPlugin() try Amplify.add(plugin: plugin) diff --git a/AmplifyTests/CategoryTests/Logging/LoggingCategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/Logging/LoggingCategoryConfigurationTests.swift index 72d8db4939..28c0e4f08d 100644 --- a/AmplifyTests/CategoryTests/Logging/LoggingCategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/Logging/LoggingCategoryConfigurationTests.swift @@ -36,6 +36,7 @@ class LoggingCategoryConfigurationTests: XCTestCase { XCTAssertNotNil(try Amplify.Logging.getPlugin(for: "MockLoggingCategoryPlugin")) } +#if swift(>=5.8) func testCanResetLoggingPlugin() async throws { let plugin = MockLoggingCategoryPlugin() let resetWasInvoked = expectation(description: "reset() was invoked") @@ -56,6 +57,7 @@ class LoggingCategoryConfigurationTests: XCTestCase { await Amplify.reset() await fulfillment(of: [resetWasInvoked], timeout: 1.0) } +#endif func testResetRemovesAddedPlugin() async throws { let plugin = MockLoggingCategoryPlugin()