File tree Expand file tree Collapse file tree 1 file changed +38
-5
lines changed
OptimizelySDK/OptimizelyTests/OptimizelyTests-Common Expand file tree Collapse file tree 1 file changed +38
-5
lines changed Original file line number Diff line number Diff line change @@ -138,12 +138,45 @@ class DatafileHandlerTests: XCTestCase {
138
138
139
139
}
140
140
141
-
142
- func testPerformanceExample( ) {
143
- // This is an example of a performance test case.
144
- self . measure {
145
- // Put the code you want to measure the time of here.
141
+ func testDownloadTimeout( ) {
142
+ let handler = DefaultDatafileHandler ( )
143
+ handler. endPointStringFormat = " https://httpstat.us/200?sleep=5000&datafile=%@ "
144
+
145
+ let expectation = XCTestExpectation ( description: " should fail before 10 " )
146
+ handler. downloadDatafile ( sdkKey: " invalidKey1212121 " , resourceTimeoutInterval: 3 ) { ( result) in
147
+ switch result {
148
+ case . failure( let error) :
149
+ print ( error)
150
+ XCTAssert ( true )
151
+ expectation. fulfill ( )
152
+ case . success( let data) :
153
+ print ( data)
154
+ XCTAssert ( false )
155
+ }
146
156
}
157
+
158
+ wait ( for: [ expectation] , timeout: 5.0 )
159
+
147
160
}
161
+
162
+ func testDownloadWithoutTimeout( ) {
163
+ let handler = DefaultDatafileHandler ( )
164
+ handler. endPointStringFormat = " https://httpstat.us/200?sleep=5000&datafile=%@ "
165
+
166
+ let expectation = XCTestExpectation ( description: " will wait for response. " )
167
+ handler. downloadDatafile ( sdkKey: " invalidKeyXXXXX " ) { ( result) in
168
+ switch result {
169
+ case . failure( let error) :
170
+ print ( error)
171
+ XCTAssert ( false )
172
+ case . success( let data) :
173
+ print ( data ?? " " )
174
+ XCTAssert ( true )
175
+ expectation. fulfill ( )
176
+ }
177
+ }
148
178
179
+ wait ( for: [ expectation] , timeout: 10.0 )
180
+
181
+ }
149
182
}
You can’t perform that action at this time.
0 commit comments