Skip to content

Commit 9550b56

Browse files
authored
chore: kickoff release
2 parents 1c97ee5 + e51aee8 commit 9550b56

File tree

57 files changed

+693
-590
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+693
-590
lines changed

AmplifyPlugins/API/Tests/AWSAPIPluginTests/AWSAPICategoryPlugin+GraphQLBehaviorTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AWSAPICategoryPluginGraphQLBehaviorTests: AWSAPICategoryPluginTestBase {
1414

1515
// MARK: Query API Tests
1616

17-
func testQuery() {
17+
func testQuery() async {
1818
let operationFinished = expectation(description: "Operation should finish")
1919
let request = GraphQLRequest<JSONValue>(apiName: apiName,
2020
document: testDocument,
@@ -39,12 +39,12 @@ class AWSAPICategoryPluginGraphQLBehaviorTests: AWSAPICategoryPluginTestBase {
3939
XCTAssertEqual(operationRequest.operationType, GraphQLOperationType.query)
4040
XCTAssertNotNil(operationRequest.options)
4141
XCTAssertNil(operationRequest.variables)
42-
waitForExpectations(timeout: 1)
42+
await fulfillment(of: [operationFinished], timeout: 1)
4343
}
4444

4545
// MARK: Mutate API Tests
4646

47-
func testMutate() {
47+
func testMutate() async {
4848
let operationFinished = expectation(description: "Operation should finish")
4949
let request = GraphQLRequest(apiName: apiName,
5050
document: testDocument,
@@ -68,12 +68,12 @@ class AWSAPICategoryPluginGraphQLBehaviorTests: AWSAPICategoryPluginTestBase {
6868
XCTAssertEqual(operationRequest.operationType, GraphQLOperationType.mutation)
6969
XCTAssertNotNil(operationRequest.options)
7070
XCTAssertNil(operationRequest.variables)
71-
waitForExpectations(timeout: 1)
71+
await fulfillment(of: [operationFinished], timeout: 1)
7272
}
7373

7474
// MARK: Subscribe API Tests
7575

76-
func testSubscribe() {
76+
func testSubscribe() async {
7777
let operationFinished = expectation(description: "Operation should finish")
7878
let request = GraphQLRequest(apiName: apiName,
7979
document: testDocument,
@@ -97,6 +97,6 @@ class AWSAPICategoryPluginGraphQLBehaviorTests: AWSAPICategoryPluginTestBase {
9797
XCTAssertEqual(operationRequest.operationType, GraphQLOperationType.subscription)
9898
XCTAssertNotNil(operationRequest.options)
9999
XCTAssertNil(operationRequest.variables)
100-
waitForExpectations(timeout: 1)
100+
await fulfillment(of: [operationFinished], timeout: 1)
101101
}
102102
}

AmplifyPlugins/API/Tests/AWSAPIPluginTests/AWSAPICategoryPlugin+RESTClientBehaviorTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AWSAPICategoryPluginRESTClientBehaviorTests: AWSAPICategoryPluginTestBase
1616

1717
// MARK: Get API tests
1818

19-
func testGet() {
19+
func testGet() async {
2020
let operationFinished = expectation(description: "Operation should finish")
2121
let request = RESTRequest(apiName: apiName, path: testPath)
2222
let operation = apiPlugin.get(request: request) { _ in
@@ -38,12 +38,12 @@ class AWSAPICategoryPluginRESTClientBehaviorTests: AWSAPICategoryPluginTestBase
3838
XCTAssertEqual(operationRequest.operationType, RESTOperationType.get)
3939
XCTAssertNotNil(operationRequest.options)
4040
XCTAssertNotNil(operationRequest.path)
41-
waitForExpectations(timeout: 1)
41+
await fulfillment(of: [operationFinished], timeout: 1)
4242
}
4343

4444
// MARK: Post API tests
4545

46-
func testPost() {
46+
func testPost() async {
4747
let operationFinished = expectation(description: "Operation should finish")
4848
let request = RESTRequest(apiName: apiName, path: testPath, body: testBody)
4949
let operation = apiPlugin.post(request: request) { _ in
@@ -65,7 +65,7 @@ class AWSAPICategoryPluginRESTClientBehaviorTests: AWSAPICategoryPluginTestBase
6565
XCTAssertEqual(operationRequest.operationType, RESTOperationType.post)
6666
XCTAssertNotNil(operationRequest.options)
6767
XCTAssertNotNil(operationRequest.path)
68-
waitForExpectations(timeout: 1)
68+
await fulfillment(of: [operationFinished], timeout: 1)
6969
}
7070

7171
// MARK: Put API tests

AmplifyPlugins/API/Tests/AWSAPIPluginTests/Operation/AWSRESTOperationTests.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AWSRESTOperationTests: OperationTestBase {
3333
}
3434

3535
// TODO: Fix this test
36-
func testGetReturnsOperation() throws {
36+
func testGetReturnsOperation() async throws {
3737
try setUpPlugin(endpointType: .rest)
3838

3939
// Use this as a semaphore to ensure the task is cleaned up before proceeding to the next test
@@ -49,11 +49,10 @@ class AWSRESTOperationTests: OperationTestBase {
4949
}
5050

5151
XCTAssertNotNil(operation.request)
52-
53-
waitForExpectations(timeout: 1.00)
52+
await fulfillment(of: [listenerWasInvoked], timeout: 1)
5453
}
5554

56-
func testGetFailsWithBadAPIName() throws {
55+
func testGetFailsWithBadAPIName() async throws {
5756
let sentData = Data([0x00, 0x01, 0x02, 0x03])
5857
try setUpPluginForSingleResponse(sending: sentData, for: .rest)
5958

@@ -71,7 +70,7 @@ class AWSRESTOperationTests: OperationTestBase {
7170
}
7271
}
7372

74-
waitForExpectations(timeout: 1.00)
73+
await fulfillment(of: [receivedFailure, receivedSuccess], timeout: 1)
7574
}
7675

7776
/// - Given: A configured plugin

AmplifyPlugins/API/Tests/AWSAPIPluginTests/Operation/GraphQLMutateCombineTests.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import XCTest
1414
class GraphQLMutateCombineTests: OperationTestBase {
1515
let testDocument = "mutate { updateTodo { id name description }}"
1616

17-
func testMutateSucceeds() throws {
17+
func testMutateSucceeds() async throws {
1818
let testJSONData: JSONValue = ["foo": true]
1919
let sentData = Data(#"{"data": {"foo": true}}"#.utf8)
2020
try setUpPluginForSingleResponse(sending: sentData, for: .graphQL)
@@ -46,12 +46,11 @@ class GraphQLMutateCombineTests: OperationTestBase {
4646
receivedResponseError.fulfill()
4747
}
4848
})
49-
50-
waitForExpectations(timeout: 0.05)
49+
await fulfillment(of: [receivedValue, receivedFinish, receivedFailure, receivedResponseError], timeout: 0.05)
5150
sink.cancel()
5251
}
5352

54-
func testMutateHandlesResponseError() throws {
53+
func testMutateHandlesResponseError() async throws {
5554
let sentData = Data(#"{"data": {"foo": true}, "errors": []}"#.utf8)
5655
try setUpPluginForSingleResponse(sending: sentData, for: .graphQL)
5756

@@ -82,12 +81,12 @@ class GraphQLMutateCombineTests: OperationTestBase {
8281
}
8382
})
8483

85-
waitForExpectations(timeout: 0.05)
84+
await fulfillment(of: [receivedValue, receivedFinish, receivedFailure, receivedResponseError], timeout: 0.05)
8685
sink.cancel()
8786

8887
}
8988

90-
func testMutateFails() throws {
89+
func testMutateFails() async throws {
9190
try setUpPluginForSingleError(for: .graphQL)
9291

9392
let request = GraphQLRequest(document: testDocument, variables: nil, responseType: JSONValue.self)
@@ -118,7 +117,7 @@ class GraphQLMutateCombineTests: OperationTestBase {
118117
}
119118
})
120119

121-
waitForExpectations(timeout: 1.0)
120+
await fulfillment(of: [receivedValue, receivedFinish, receivedFailure, receivedResponseError], timeout: 1)
122121
sink.cancel()
123122
}
124123
}

AmplifyPlugins/API/Tests/AWSAPIPluginTests/Operation/GraphQLQueryCombineTests.swift

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import XCTest
1414
class GraphQLQueryCombineTests: OperationTestBase {
1515
let testDocument = "query { getTodo { id name description }}"
1616

17-
func testQuerySucceeds() throws {
17+
func testQuerySucceeds() async throws {
1818
let testJSONData: JSONValue = ["foo": true]
1919
let sentData = Data(#"{"data": {"foo": true}}"#.utf8)
2020
try setUpPluginForSingleResponse(sending: sentData, for: .graphQL)
@@ -47,11 +47,16 @@ class GraphQLQueryCombineTests: OperationTestBase {
4747
}
4848
})
4949

50-
waitForExpectations(timeout: 0.05)
50+
await fulfillment(of: [receivedValue,
51+
receivedFinish,
52+
receivedFailure,
53+
receivedResponseError
54+
],
55+
timeout: 0.05)
5156
sink.cancel()
5257
}
5358

54-
func testQueryHandlesResponseError() throws {
59+
func testQueryHandlesResponseError() async throws {
5560
let sentData = Data(#"{"data": {"foo": true}, "errors": []}"#.utf8)
5661
try setUpPluginForSingleResponse(sending: sentData, for: .graphQL)
5762

@@ -82,12 +87,17 @@ class GraphQLQueryCombineTests: OperationTestBase {
8287
}
8388
})
8489

85-
waitForExpectations(timeout: 0.05)
90+
await fulfillment(of: [receivedValue,
91+
receivedFinish,
92+
receivedFailure,
93+
receivedResponseError
94+
],
95+
timeout: 0.05)
8696
sink.cancel()
8797

8898
}
8999

90-
func testQueryFails() throws {
100+
func testQueryFails() async throws {
91101
try setUpPluginForSingleError(for: .graphQL)
92102

93103
let request = GraphQLRequest(document: testDocument, variables: nil, responseType: JSONValue.self)
@@ -118,7 +128,12 @@ class GraphQLQueryCombineTests: OperationTestBase {
118128
}
119129
})
120130

121-
waitForExpectations(timeout: 0.05)
131+
await fulfillment(of: [receivedValue,
132+
receivedFinish,
133+
receivedFailure,
134+
receivedResponseError
135+
],
136+
timeout: 0.05)
122137
sink.cancel()
123138
}
124139
}

AmplifyPlugins/API/Tests/AWSAPIPluginTests/Operation/GraphQLSubscribeTests.swift

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,14 @@ class GraphQLSubscribeTests: OperationTestBase {
102102
mockAppSyncRealTimeClient.triggerEvent(.data(testData))
103103
mockAppSyncRealTimeClient.triggerEvent(.unsubscribed)
104104

105-
await waitForExpectations(timeout: 0.05)
105+
await fulfillment(of: [receivedCompletionFinish,
106+
receivedCompletionFailure,
107+
receivedConnected,
108+
receivedDisconnected,
109+
receivedSubscriptionEventData,
110+
receivedSubscriptionEventError
111+
],
112+
timeout: 0.05)
106113
}
107114

108115
/// Lifecycle test
@@ -131,7 +138,14 @@ class GraphQLSubscribeTests: OperationTestBase {
131138
try await MockAppSyncRealTimeClient.waitForSubscirbed()
132139
mockAppSyncRealTimeClient.triggerEvent(.unsubscribed)
133140

134-
await waitForExpectations(timeout: 0.05)
141+
await fulfillment(of: [receivedCompletionFinish,
142+
receivedCompletionFailure,
143+
receivedConnected,
144+
receivedDisconnected,
145+
receivedSubscriptionEventData,
146+
receivedSubscriptionEventError
147+
],
148+
timeout: 0.05)
135149
}
136150

137151
/// Lifecycle test
@@ -158,7 +172,14 @@ class GraphQLSubscribeTests: OperationTestBase {
158172
try await MockAppSyncRealTimeClient.waitForSubscirbing()
159173
mockAppSyncRealTimeClient.triggerEvent(.error(["Error"]))
160174

161-
await waitForExpectations(timeout: 0.05)
175+
await fulfillment(of: [receivedCompletionFinish,
176+
receivedCompletionFailure,
177+
receivedConnected,
178+
receivedDisconnected,
179+
receivedSubscriptionEventData,
180+
receivedSubscriptionEventError
181+
],
182+
timeout: 0.05)
162183
}
163184

164185
/// Lifecycle test
@@ -193,7 +214,14 @@ class GraphQLSubscribeTests: OperationTestBase {
193214
mockAppSyncRealTimeClient.triggerEvent(.data(testData))
194215
mockAppSyncRealTimeClient.triggerEvent(.unsubscribed)
195216

196-
await waitForExpectations(timeout: 0.05)
217+
await fulfillment(of: [receivedCompletionFinish,
218+
receivedCompletionFailure,
219+
receivedConnected,
220+
receivedDisconnected,
221+
receivedSubscriptionEventData,
222+
receivedSubscriptionEventError
223+
],
224+
timeout: 0.05)
197225
}
198226

199227
func testMultipleSuccessValues() async throws {
@@ -220,7 +248,14 @@ class GraphQLSubscribeTests: OperationTestBase {
220248
mockAppSyncRealTimeClient.triggerEvent(.data(testData))
221249
mockAppSyncRealTimeClient.triggerEvent(.unsubscribed)
222250

223-
await waitForExpectations(timeout: 0.05)
251+
await fulfillment(of: [receivedCompletionFinish,
252+
receivedCompletionFailure,
253+
receivedConnected,
254+
receivedDisconnected,
255+
receivedSubscriptionEventData,
256+
receivedSubscriptionEventError
257+
],
258+
timeout: 0.05)
224259
}
225260

226261
func testMixedSuccessAndErrorValues() async throws {
@@ -253,7 +288,14 @@ class GraphQLSubscribeTests: OperationTestBase {
253288
mockAppSyncRealTimeClient.triggerEvent(.data(successfulTestData))
254289
mockAppSyncRealTimeClient.triggerEvent(.unsubscribed)
255290

256-
await waitForExpectations(timeout: 0.05)
291+
await fulfillment(of: [receivedCompletionFinish,
292+
receivedCompletionFailure,
293+
receivedConnected,
294+
receivedDisconnected,
295+
receivedSubscriptionEventData,
296+
receivedSubscriptionEventError
297+
],
298+
timeout: 0.05)
257299
}
258300

259301
// MARK: - Utilities

AmplifyPlugins/API/Tests/AWSAPIPluginTests/Operation/RESTCombineTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import XCTest
1313

1414
class RESTCombineTests: OperationTestBase {
1515

16-
func testGetSucceeds() throws {
16+
func testGetSucceeds() async throws {
1717
let sentData = Data([0x00, 0x01, 0x02, 0x03])
1818
try setUpPluginForSingleResponse(sending: sentData, for: .graphQL)
1919

@@ -38,11 +38,11 @@ class RESTCombineTests: OperationTestBase {
3838
receivedValue.fulfill()
3939
})
4040

41-
waitForExpectations(timeout: 0.05)
41+
await fulfillment(of: [receivedValue, receivedFinish, receivedFailure], timeout: 0.05)
4242
sink.cancel()
4343
}
4444

45-
func testGetFails() throws {
45+
func testGetFails() async throws {
4646
let sentData = Data([0x00, 0x01, 0x02, 0x03])
4747
try setUpPluginForSingleError(for: .graphQL)
4848

@@ -68,7 +68,7 @@ class RESTCombineTests: OperationTestBase {
6868
receivedValue.fulfill()
6969
})
7070

71-
waitForExpectations(timeout: 0.05)
71+
await fulfillment(of: [receivedValue, receivedFinish, receivedFailure], timeout: 0.05)
7272
sink.cancel()
7373
}
7474
}

AmplifyPlugins/API/Tests/AWSAPIPluginTests/Reachability/NetworkReachabilityNotifierTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class NetworkReachabilityNotifierTests: XCTestCase {
2828
MockReachability.iConnection = .wifi
2929
}
3030

31-
func testWifiConnectivity() {
31+
func testWifiConnectivity() async {
3232
MockReachability.iConnection = .wifi
3333
let expect = expectation(description: ".sink receives values")
3434
var values = [Bool]()
@@ -45,11 +45,11 @@ class NetworkReachabilityNotifierTests: XCTestCase {
4545
notification = Notification.init(name: .reachabilityChanged)
4646
NotificationCenter.default.post(notification)
4747

48-
waitForExpectations(timeout: 1.0)
48+
await fulfillment(of: [expect], timeout: 1)
4949
cancellable.cancel()
5050
}
5151

52-
func testCellularConnectivity() {
52+
func testCellularConnectivity() async {
5353
MockReachability.iConnection = .wifi
5454
let expect = expectation(description: ".sink receives values")
5555
var values = [Bool]()
@@ -67,11 +67,11 @@ class NetworkReachabilityNotifierTests: XCTestCase {
6767
notification = Notification.init(name: .reachabilityChanged)
6868
NotificationCenter.default.post(notification)
6969

70-
waitForExpectations(timeout: 1.0)
70+
await fulfillment(of: [expect], timeout: 1)
7171
cancellable.cancel()
7272
}
7373

74-
func testNoConnectivity() {
74+
func testNoConnectivity() async {
7575
MockReachability.iConnection = .unavailable
7676
let expect = expectation(description: ".sink receives values")
7777
var values = [Bool]()
@@ -89,7 +89,7 @@ class NetworkReachabilityNotifierTests: XCTestCase {
8989
notification = Notification.init(name: .reachabilityChanged)
9090
NotificationCenter.default.post(notification)
9191

92-
waitForExpectations(timeout: 1.0)
92+
await fulfillment(of: [expect], timeout: 1)
9393
cancellable.cancel()
9494
}
9595

0 commit comments

Comments
 (0)