@@ -83,7 +83,7 @@ class IntegrationTests: XCTestCase {
83
83
return URL ( string: " http://localhost:5005/functions-integration-test/us-central1/ \( funcName) " ) !
84
84
}
85
85
86
- func testData( ) {
86
+ @ MainActor func testData( ) {
87
87
let data = DataTestRequest (
88
88
bool: true ,
89
89
int: 2 ,
@@ -148,7 +148,7 @@ class IntegrationTests: XCTestCase {
148
148
}
149
149
}
150
150
151
- func testScalar( ) {
151
+ @ MainActor func testScalar( ) {
152
152
let byName = functions. httpsCallable (
153
153
" scalarTest " ,
154
154
requestAs: Int16 . self,
@@ -203,7 +203,7 @@ class IntegrationTests: XCTestCase {
203
203
}
204
204
}
205
205
206
- func testToken( ) {
206
+ @ MainActor func testToken( ) {
207
207
// Recreate functions with a token.
208
208
let functions = Functions (
209
209
projectID: " functions-integration-test " ,
@@ -271,7 +271,7 @@ class IntegrationTests: XCTestCase {
271
271
}
272
272
}
273
273
274
- func testFCMToken( ) {
274
+ @ MainActor func testFCMToken( ) {
275
275
let byName = functions. httpsCallable (
276
276
" FCMTokenTest " ,
277
277
requestAs: [ String : Int ] . self,
@@ -316,7 +316,7 @@ class IntegrationTests: XCTestCase {
316
316
}
317
317
}
318
318
319
- func testNull( ) {
319
+ @ MainActor func testNull( ) {
320
320
let byName = functions. httpsCallable (
321
321
" nullTest " ,
322
322
requestAs: Int ? . self,
@@ -361,7 +361,7 @@ class IntegrationTests: XCTestCase {
361
361
}
362
362
}
363
363
364
- func testMissingResult( ) {
364
+ @ MainActor func testMissingResult( ) {
365
365
let byName = functions. httpsCallable (
366
366
" missingResultTest " ,
367
367
requestAs: Int ? . self,
@@ -415,7 +415,7 @@ class IntegrationTests: XCTestCase {
415
415
}
416
416
}
417
417
418
- func testUnhandledError( ) {
418
+ @ MainActor func testUnhandledError( ) {
419
419
let byName = functions. httpsCallable (
420
420
" unhandledErrorTest " ,
421
421
requestAs: [ Int ] . self,
@@ -469,7 +469,7 @@ class IntegrationTests: XCTestCase {
469
469
}
470
470
}
471
471
472
- func testUnknownError( ) {
472
+ @ MainActor func testUnknownError( ) {
473
473
let byName = functions. httpsCallable (
474
474
" unknownErrorTest " ,
475
475
requestAs: [ Int ] . self,
@@ -522,7 +522,7 @@ class IntegrationTests: XCTestCase {
522
522
}
523
523
}
524
524
525
- func testExplicitError( ) {
525
+ @ MainActor func testExplicitError( ) {
526
526
let byName = functions. httpsCallable (
527
527
" explicitErrorTest " ,
528
528
requestAs: [ Int ] . self,
@@ -579,7 +579,7 @@ class IntegrationTests: XCTestCase {
579
579
}
580
580
}
581
581
582
- func testHttpError( ) {
582
+ @ MainActor func testHttpError( ) {
583
583
let byName = functions. httpsCallable (
584
584
" httpErrorTest " ,
585
585
requestAs: [ Int ] . self,
@@ -631,7 +631,7 @@ class IntegrationTests: XCTestCase {
631
631
}
632
632
}
633
633
634
- func testThrowError( ) {
634
+ @ MainActor func testThrowError( ) {
635
635
let byName = functions. httpsCallable (
636
636
" throwTest " ,
637
637
requestAs: [ Int ] . self,
@@ -685,7 +685,7 @@ class IntegrationTests: XCTestCase {
685
685
}
686
686
}
687
687
688
- func testTimeout( ) {
688
+ @ MainActor func testTimeout( ) {
689
689
let byName = functions. httpsCallable (
690
690
" timeoutTest " ,
691
691
requestAs: [ Int ] . self,
@@ -743,7 +743,7 @@ class IntegrationTests: XCTestCase {
743
743
}
744
744
}
745
745
746
- func testCallAsFunction( ) {
746
+ @ MainActor func testCallAsFunction( ) {
747
747
let data = DataTestRequest (
748
748
bool: true ,
749
749
int: 2 ,
@@ -808,7 +808,7 @@ class IntegrationTests: XCTestCase {
808
808
}
809
809
}
810
810
811
- func testInferredTypes( ) {
811
+ @ MainActor func testInferredTypes( ) {
812
812
let data = DataTestRequest (
813
813
bool: true ,
814
814
int: 2 ,
@@ -868,7 +868,7 @@ class IntegrationTests: XCTestCase {
868
868
}
869
869
}
870
870
871
- func testFunctionsReturnsOnMainThread( ) {
871
+ @ MainActor func testFunctionsReturnsOnMainThread( ) {
872
872
let expectation = expectation ( description: #function)
873
873
functions. httpsCallable (
874
874
" scalarTest " ,
@@ -884,7 +884,7 @@ class IntegrationTests: XCTestCase {
884
884
waitForExpectations ( timeout: 5 )
885
885
}
886
886
887
- func testFunctionsThrowsOnMainThread( ) {
887
+ @ MainActor func testFunctionsThrowsOnMainThread( ) {
888
888
let expectation = expectation ( description: #function)
889
889
functions. httpsCallable (
890
890
" httpErrorTest " ,
@@ -908,7 +908,7 @@ class IntegrationTests: XCTestCase {
908
908
///
909
909
/// This can be used as the generic `Request` parameter to ``Callable`` to
910
910
/// indicate the callable function does not accept parameters.
911
- private struct EmptyRequest : Encodable { }
911
+ private struct EmptyRequest : Encodable , Sendable { }
912
912
913
913
@available ( macOS 12 . 0 , iOS 15 . 0 , watchOS 8 . 0 , tvOS 15 . 0 , * )
914
914
extension IntegrationTests {
@@ -1100,18 +1100,21 @@ extension IntegrationTests {
1100
1100
)
1101
1101
}
1102
1102
1103
- func testStream_Canceled( ) async throws {
1104
- let task = Task . detached { [ self ] in
1105
- let callable : Callable < EmptyRequest , String > = functions. httpsCallable ( " genStream " )
1106
- let stream = try callable. stream ( )
1107
- // Since we cancel the call we are expecting an empty array.
1108
- return try await stream. reduce ( [ ] ) { $0 + [ $1] } as [ String ]
1103
+ // Concurrency rules prevent easily testing this feature.
1104
+ #if swift(<6)
1105
+ func testStream_Canceled( ) async throws {
1106
+ let task = Task . detached { [ self ] in
1107
+ let callable : Callable < EmptyRequest , String > = functions. httpsCallable ( " genStream " )
1108
+ let stream = try callable. stream ( )
1109
+ // Since we cancel the call we are expecting an empty array.
1110
+ return try await stream. reduce ( [ ] ) { $0 + [ $1] } as [ String ]
1111
+ }
1112
+ // We cancel the task and we expect a null response even if the stream was initiated.
1113
+ task. cancel ( )
1114
+ let respone = try await task. value
1115
+ XCTAssertEqual ( respone, [ ] )
1109
1116
}
1110
- // We cancel the task and we expect a null response even if the stream was initiated.
1111
- task. cancel ( )
1112
- let respone = try await task. value
1113
- XCTAssertEqual ( respone, [ ] )
1114
- }
1117
+ #endif
1115
1118
1116
1119
func testStream_NonexistentFunction( ) async throws {
1117
1120
let callable : Callable < EmptyRequest , String > = functions. httpsCallable (
@@ -1163,7 +1166,8 @@ extension IntegrationTests {
1163
1166
func testStream_ResultIsOnlyExposedInStreamResponse( ) async throws {
1164
1167
// The implementation is copied from `StreamResponse`. The only difference is the do-catch is
1165
1168
// removed from the decoding initializer.
1166
- enum MyStreamResponse < Message: Decodable , Result: Decodable > : Decodable {
1169
+ enum MyStreamResponse < Message: Decodable & Sendable , Result: Decodable & Sendable > : Decodable ,
1170
+ Sendable {
1167
1171
/// The message yielded by the callable function.
1168
1172
case message( Message )
1169
1173
/// The final result returned by the callable function.
@@ -1248,7 +1252,7 @@ extension IntegrationTests {
1248
1252
}
1249
1253
1250
1254
func testStream_ResultOnly_StreamResponse( ) async throws {
1251
- struct EmptyResponse : Decodable { }
1255
+ struct EmptyResponse : Decodable , Sendable { }
1252
1256
let callable : Callable < EmptyRequest , StreamResponse < EmptyResponse , String > > = functions
1253
1257
. httpsCallable (
1254
1258
" genStreamResultOnly "
0 commit comments