@@ -17,6 +17,13 @@ import XCTest
17
17
18
18
@testable import FirebaseSessions
19
19
20
+ private class SendableBox < Value> : @unchecked Sendable {
21
+ var value : Value
22
+ init ( value: Value ) {
23
+ self . value = value
24
+ }
25
+ }
26
+
20
27
class SessionCoordinatorTests : XCTestCase {
21
28
var installations = MockInstallationsProtocol ( )
22
29
var time = MockTimeProvider ( )
@@ -50,13 +57,13 @@ class SessionCoordinatorTests: XCTestCase {
50
57
51
58
func test_attemptLoggingSessionStart_logsToGDT( ) throws {
52
59
let event = SessionStartEvent ( sessionInfo: defaultSessionInfo, appInfo: appInfo, time: time)
53
- var resultSuccess = false
60
+ let resultSuccess = SendableBox ( value : false )
54
61
coordinator. attemptLoggingSessionStart ( event: event) { result in
55
62
switch result {
56
63
case . success( ( ) ) :
57
- resultSuccess = true
64
+ resultSuccess. value = true
58
65
case . failure:
59
- resultSuccess = false
66
+ resultSuccess. value = false
60
67
}
61
68
}
62
69
// Make sure we've set the Installation ID
@@ -71,7 +78,7 @@ class SessionCoordinatorTests: XCTestCase {
71
78
72
79
// We should have logged successfully
73
80
XCTAssertEqual ( fireLogger. loggedEvent, event)
74
- XCTAssert ( resultSuccess)
81
+ XCTAssert ( resultSuccess. value )
75
82
}
76
83
77
84
func test_attemptLoggingSessionStart_handlesGDTError( ) throws {
@@ -80,13 +87,13 @@ class SessionCoordinatorTests: XCTestCase {
80
87
let event = SessionStartEvent ( sessionInfo: defaultSessionInfo, appInfo: appInfo, time: time)
81
88
82
89
// Start success so it must be set to false
83
- var resultSuccess = true
90
+ let resultSuccess = SendableBox ( value : true )
84
91
coordinator. attemptLoggingSessionStart ( event: event) { result in
85
92
switch result {
86
93
case . success( ( ) ) :
87
- resultSuccess = true
94
+ resultSuccess. value = true
88
95
case . failure:
89
- resultSuccess = false
96
+ resultSuccess. value = false
90
97
}
91
98
}
92
99
@@ -102,7 +109,7 @@ class SessionCoordinatorTests: XCTestCase {
102
109
103
110
// We should have logged the event, but with a failed result
104
111
XCTAssertEqual ( fireLogger. loggedEvent, event)
105
- XCTAssertFalse ( resultSuccess)
112
+ XCTAssertFalse ( resultSuccess. value )
106
113
}
107
114
108
115
func test_attemptLoggingSessionStart_handlesInstallationsError( ) throws {
@@ -111,21 +118,21 @@ class SessionCoordinatorTests: XCTestCase {
111
118
let event = SessionStartEvent ( sessionInfo: defaultSessionInfo, appInfo: appInfo, time: time)
112
119
113
120
// Start success so it must be set to false
114
- var resultSuccess = true
121
+ let resultSuccess = SendableBox ( value : true )
115
122
coordinator. attemptLoggingSessionStart ( event: event) { result in
116
123
switch result {
117
124
case . success( ( ) ) :
118
- resultSuccess = true
125
+ resultSuccess. value = true
119
126
case . failure:
120
- resultSuccess = false
127
+ resultSuccess. value = false
121
128
}
122
129
}
123
130
124
131
XCTAssertTrue ( installations. authTokenFinished)
125
132
XCTAssertTrue ( installations. installationIdFinished)
126
133
// We should have logged the event, but with a failed result
127
134
XCTAssertNotNil ( fireLogger. loggedEvent)
128
- XCTAssertFalse ( resultSuccess)
135
+ XCTAssertFalse ( resultSuccess. value )
129
136
}
130
137
131
138
func test_attemptLoggingSessionStart_handlesGDTAndInstallationsError( ) throws {
@@ -138,13 +145,13 @@ class SessionCoordinatorTests: XCTestCase {
138
145
let event = SessionStartEvent ( sessionInfo: defaultSessionInfo, appInfo: appInfo, time: time)
139
146
140
147
// Start success so it must be set to false
141
- var resultSuccess = true
148
+ let resultSuccess = SendableBox ( value : true )
142
149
coordinator. attemptLoggingSessionStart ( event: event) { result in
143
150
switch result {
144
151
case . success( ( ) ) :
145
- resultSuccess = true
152
+ resultSuccess. value = true
146
153
case let . failure( err) :
147
- resultSuccess = false
154
+ resultSuccess. value = false
148
155
// Result should use the FireLog error if there's an error in both
149
156
// Installations and FireLog
150
157
XCTAssertEqual ( err, FirebaseSessionsError . DataTransportError ( fireLogError) )
@@ -164,6 +171,6 @@ class SessionCoordinatorTests: XCTestCase {
164
171
165
172
// We should have logged the event, but with a failed result
166
173
XCTAssertEqual ( fireLogger. loggedEvent, event)
167
- XCTAssertFalse ( resultSuccess)
174
+ XCTAssertFalse ( resultSuccess. value )
168
175
}
169
176
}
0 commit comments