Skip to content

Commit 1104c72

Browse files
authored
Storage Integration Test flakiness (#12235)
1 parent 0fe8385 commit 1104c72

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

FirebaseStorage/Tests/Integration/StorageAsyncAwait.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class StorageAsyncAwait: StorageIntegrationCommon {
151151
let ref = storage.reference(withPath: "ios/public/" + fileName)
152152
let data = try XCTUnwrap("Hello Swift World".data(using: .utf8), "Data construction failed")
153153
let tmpDirURL = URL(fileURLWithPath: NSTemporaryDirectory())
154-
let fileURL = tmpDirURL.appendingPathComponent("hello.txt")
154+
let fileURL = tmpDirURL.appendingPathComponent(#function + "hello.txt")
155155
try data.write(to: fileURL, options: .atomicWrite)
156156
let metadata = try await ref.putFileAsync(from: fileURL)
157157
XCTAssertEqual(fileName, metadata.name)
@@ -182,7 +182,7 @@ class StorageAsyncAwait: StorageIntegrationCommon {
182182
let ref = storage.reference(withPath: "ios/public/testSimplePutFile")
183183
let data = try XCTUnwrap("Hello Swift World".data(using: .utf8), "Data construction failed")
184184
let tmpDirURL = URL(fileURLWithPath: NSTemporaryDirectory())
185-
let fileURL = tmpDirURL.appendingPathComponent("hello.txt")
185+
let fileURL = tmpDirURL.appendingPathComponent(#function + "hello.txt")
186186
try data.write(to: fileURL, options: .atomicWrite)
187187
var uploadedBytes: Int64 = -1
188188
let successMetadata = try await ref.putFileAsync(from: fileURL) { progress in
@@ -251,21 +251,21 @@ class StorageAsyncAwait: StorageIntegrationCommon {
251251
}
252252

253253
func testAsyncWrite() async throws {
254-
let ref = storage.reference(withPath: "ios/public/helloworld")
254+
let ref = storage.reference(withPath: "ios/public/helloworld" + #function)
255255
let tmpDirURL = URL(fileURLWithPath: NSTemporaryDirectory())
256-
let fileURL = tmpDirURL.appendingPathComponent("hello.txt")
256+
let fileURL = tmpDirURL.appendingPathComponent(#function + "hello.txt")
257257
let data = try XCTUnwrap("Hello Swift World".data(using: .utf8), "Data construction failed")
258258

259259
_ = try await ref.putDataAsync(data)
260260
let url = try await ref.writeAsync(toFile: fileURL)
261-
XCTAssertEqual(url.lastPathComponent, "hello.txt")
261+
XCTAssertEqual(url.lastPathComponent, #function + "hello.txt")
262262
}
263263

264264
func testSimpleGetFile() throws {
265265
let expectation = self.expectation(description: #function)
266-
let ref = storage.reference(withPath: "ios/public/helloworld")
266+
let ref = storage.reference(withPath: "ios/public/helloworld" + #function)
267267
let tmpDirURL = URL(fileURLWithPath: NSTemporaryDirectory())
268-
let fileURL = tmpDirURL.appendingPathComponent("hello.txt")
268+
let fileURL = tmpDirURL.appendingPathComponent(#function + "hello.txt")
269269
let data = try XCTUnwrap("Hello Swift World".data(using: .utf8), "Data construction failed")
270270

271271
Task {

FirebaseStorage/Tests/Integration/StorageIntegration.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,9 @@ class StorageResultTests: StorageIntegrationCommon {
535535

536536
func testSimpleGetFile() throws {
537537
let expectation = self.expectation(description: #function)
538-
let ref = storage.reference(withPath: "ios/public/helloworld")
538+
let ref = storage.reference(withPath: "ios/public/helloworld" + #function)
539539
let tmpDirURL = URL(fileURLWithPath: NSTemporaryDirectory())
540-
let fileURL = tmpDirURL.appendingPathComponent("hello.txt")
540+
let fileURL = tmpDirURL.appendingPathComponent(#function + "hello.txt")
541541
let data = try XCTUnwrap("Hello Swift World".data(using: .utf8), "Data construction failed")
542542

543543
ref.putData(data) { result in
@@ -577,16 +577,15 @@ class StorageResultTests: StorageIntegrationCommon {
577577

578578
func testCancelErrorCode() throws {
579579
let expectation = self.expectation(description: #function)
580-
let ref = storage.reference(withPath: "ios/public/helloworld")
580+
let ref = storage.reference(withPath: "ios/public/helloworld" + #function)
581581
let tmpDirURL = URL(fileURLWithPath: NSTemporaryDirectory())
582-
let fileURL = tmpDirURL.appendingPathComponent("hello.txt")
582+
let fileURL = tmpDirURL.appendingPathComponent(#function + "hello.txt")
583583
let data = try XCTUnwrap("Hello Swift World".data(using: .utf8), "Data construction failed")
584584

585585
ref.putData(data) { result in
586586
switch result {
587587
case .success:
588588
let task = ref.write(toFile: fileURL)
589-
task.cancel()
590589

591590
task.observe(StorageTaskStatus.success) { snapshot in
592591
XCTFail("Error processing success snapshot")
@@ -603,6 +602,7 @@ class StorageResultTests: StorageIntegrationCommon {
603602
}
604603
expectation.fulfill()
605604
}
605+
task.cancel()
606606
case let .failure(error):
607607
XCTFail("Unexpected error \(error) from putData")
608608
expectation.fulfill()

0 commit comments

Comments
 (0)