Skip to content

Commit

Permalink
add availablility with filter version
Browse files Browse the repository at this point in the history
  • Loading branch information
5d committed Jan 12, 2024
1 parent 1d2f719 commit 8c73619
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
// SPDX-License-Identifier: Apache-2.0
//

#if swift(>=5.8)
import XCTest
@testable import Amplify
import AWSDataStorePlugin
Expand Down Expand Up @@ -41,3 +41,4 @@ class AWSDataStorePluginConfigurationTests: XCTestCase {
}

}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -374,4 +374,5 @@ class APICategoryConfigurationTests: XCTestCase {
}

}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -317,4 +317,5 @@ class AnalyticsCategoryConfigurationTests: XCTestCase {
}

}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -435,4 +435,5 @@ class AuthCategoryConfigurationTests: XCTestCase {
}

}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
// SPDX-License-Identifier: Apache-2.0
//

#if swift(>=5.8)
import XCTest
@testable import Amplify
@testable import AmplifyTestCommon
Expand Down Expand Up @@ -59,3 +59,4 @@ class TestModel: Model {
self.id = id
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
// SPDX-License-Identifier: Apache-2.0
//

#if swift(>=5.8)
import XCTest
@testable import Amplify

Expand Down Expand Up @@ -142,3 +142,4 @@ extension ListTests {
await fulfillment(of: [getNextPageSuccess], timeout: 1.0)
}
}
#endif
2 changes: 2 additions & 0 deletions AmplifyTests/CategoryTests/DataStore/Model/ListTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// SPDX-License-Identifier: Apache-2.0
//

#if swift(>=5.8)
import XCTest

@testable import Amplify
Expand Down Expand Up @@ -255,3 +256,4 @@ class ListTests: XCTestCase {
return try decoder.decode(List<R>.self, from: data)
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// SPDX-License-Identifier: Apache-2.0
//

#if swift(>=5.8)
import XCTest
@testable import Amplify
@testable import AmplifyTestCommon
Expand Down Expand Up @@ -103,3 +104,4 @@ class ModelFieldAssociationTests: XCTestCase {
}

}
#endif
2 changes: 1 addition & 1 deletion AmplifyTests/CategoryTests/DataStore/TemporalTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -81,5 +82,5 @@ class DefaultHubPluginConcurrencyTests: XCTestCase {

await fulfillment(of: messagesReceived, timeout: 5.0)
}

#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -104,5 +105,5 @@ class DefaultHubPluginCustomChannelTests: XCTestCase {

await fulfillment(of: [listener1Invoked, listener2Invoked], timeout: 0.5)
}

#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
Expand Down

0 comments on commit 8c73619

Please sign in to comment.