@@ -265,55 +265,54 @@ class StorageResultTests: StorageIntegrationCommon {
265
265
waitForExpectations ( )
266
266
}
267
267
268
- // TODO: Re-enable test before merging
269
- // func testPutFileLimitedChunk() throws {
270
- // defer {
271
- // // Reset since tests share storage instance.
272
- // storage.uploadChunkSizeBytes = Int64.max
273
- // }
274
- // let expectation = self.expectation(description: #function)
275
- // let putFileExpectation = self.expectation(description: "putFile")
276
- // let ref = storage.reference(withPath: "ios/public/testPutFilePauseResume")
277
- // let bundle = Bundle(for: StorageIntegrationCommon.self)
278
- // let filePath = try XCTUnwrap(bundle.path(forResource: "1mb", ofType: "dat"),
279
- // "Failed to get filePath")
280
- // let data = try XCTUnwrap(Data(contentsOf: URL(fileURLWithPath: filePath)),
281
- // "Failed to load file")
282
- // let tmpDirURL = URL(fileURLWithPath: NSTemporaryDirectory())
283
- // let fileURL = tmpDirURL.appendingPathComponent("LargePutFile.txt")
284
- // var progressCount = 0
285
- //
286
- // try data.write(to: fileURL, options: .atomicWrite)
287
- //
288
- // // Limit the upload chunk size
289
- // storage.uploadChunkSizeBytes = 256_000
290
- //
291
- // let task = ref.putFile(from: fileURL) { result in
292
- // XCTAssertGreaterThanOrEqual(progressCount, 4)
293
- // self.assertResultSuccess(result)
294
- // putFileExpectation.fulfill()
295
- // }
296
- //
297
- // task.observe(StorageTaskStatus.success) { snapshot in
298
- // XCTAssertEqual(snapshot.description, "<State: Success>")
299
- // expectation.fulfill()
300
- // }
301
- //
302
- // var uploadedBytes: Int64 = -1
303
- //
304
- // task.observe(StorageTaskStatus.progress) { snapshot in
305
- // XCTAssertTrue(snapshot.description.starts(with: "<State: Progress") ||
306
- // snapshot.description.starts(with: "<State: Resume"))
307
- // guard let progress = snapshot.progress else {
308
- // XCTFail("Failed to get snapshot.progress")
309
- // return
310
- // }
311
- // progressCount = progressCount + 1
312
- // XCTAssertGreaterThanOrEqual(progress.completedUnitCount, uploadedBytes)
313
- // uploadedBytes = progress.completedUnitCount
314
- // }
315
- // waitForExpectations()
316
- // }
268
+ func testPutFileLimitedChunk( ) throws {
269
+ defer {
270
+ // Reset since tests share storage instance.
271
+ storage. uploadChunkSizeBytes = Int64 . max
272
+ }
273
+ let expectation = self . expectation ( description: #function)
274
+ let putFileExpectation = self . expectation ( description: " putFile " )
275
+ let ref = storage. reference ( withPath: " ios/public/testPutFilePauseResume " )
276
+ let bundle = Bundle ( for: StorageIntegrationCommon . self)
277
+ let filePath = try XCTUnwrap ( bundle. path ( forResource: " 1mb " , ofType: " dat " ) ,
278
+ " Failed to get filePath " )
279
+ let data = try XCTUnwrap ( Data ( contentsOf: URL ( fileURLWithPath: filePath) ) ,
280
+ " Failed to load file " )
281
+ let tmpDirURL = URL ( fileURLWithPath: NSTemporaryDirectory ( ) )
282
+ let fileURL = tmpDirURL. appendingPathComponent ( " LargePutFile.txt " )
283
+ var progressCount = 0
284
+
285
+ try data. write ( to: fileURL, options: . atomicWrite)
286
+
287
+ // Limit the upload chunk size
288
+ storage. uploadChunkSizeBytes = 256_000
289
+
290
+ let task = ref. putFile ( from: fileURL) { result in
291
+ XCTAssertGreaterThanOrEqual ( progressCount, 4 )
292
+ self . assertResultSuccess ( result)
293
+ putFileExpectation. fulfill ( )
294
+ }
295
+
296
+ task. observe ( StorageTaskStatus . success) { snapshot in
297
+ XCTAssertEqual ( snapshot. description, " <State: Success> " )
298
+ expectation. fulfill ( )
299
+ }
300
+
301
+ var uploadedBytes : Int64 = - 1
302
+
303
+ task. observe ( StorageTaskStatus . progress) { snapshot in
304
+ XCTAssertTrue ( snapshot. description. starts ( with: " <State: Progress " ) ||
305
+ snapshot. description. starts ( with: " <State: Resume " ) )
306
+ guard let progress = snapshot. progress else {
307
+ XCTFail ( " Failed to get snapshot.progress " )
308
+ return
309
+ }
310
+ progressCount = progressCount + 1
311
+ XCTAssertGreaterThanOrEqual ( progress. completedUnitCount, uploadedBytes)
312
+ uploadedBytes = progress. completedUnitCount
313
+ }
314
+ waitForExpectations ( )
315
+ }
317
316
318
317
func testPutFileTinyChunk( ) throws {
319
318
defer {
0 commit comments