Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage Integration Test flakiness #12235

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions FirebaseStorage/Tests/Integration/StorageAsyncAwait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class StorageAsyncAwait: StorageIntegrationCommon {
let ref = storage.reference(withPath: "ios/public/" + fileName)
let data = try XCTUnwrap("Hello Swift World".data(using: .utf8), "Data construction failed")
let tmpDirURL = URL(fileURLWithPath: NSTemporaryDirectory())
let fileURL = tmpDirURL.appendingPathComponent("hello.txt")
let fileURL = tmpDirURL.appendingPathComponent(#function + "hello.txt")
paulb777 marked this conversation as resolved.
Show resolved Hide resolved
try data.write(to: fileURL, options: .atomicWrite)
let metadata = try await ref.putFileAsync(from: fileURL)
XCTAssertEqual(fileName, metadata.name)
Expand Down Expand Up @@ -182,7 +182,7 @@ class StorageAsyncAwait: StorageIntegrationCommon {
let ref = storage.reference(withPath: "ios/public/testSimplePutFile")
let data = try XCTUnwrap("Hello Swift World".data(using: .utf8), "Data construction failed")
let tmpDirURL = URL(fileURLWithPath: NSTemporaryDirectory())
let fileURL = tmpDirURL.appendingPathComponent("hello.txt")
let fileURL = tmpDirURL.appendingPathComponent(#function + "hello.txt")
try data.write(to: fileURL, options: .atomicWrite)
var uploadedBytes: Int64 = -1
let successMetadata = try await ref.putFileAsync(from: fileURL) { progress in
Expand Down Expand Up @@ -251,21 +251,21 @@ class StorageAsyncAwait: StorageIntegrationCommon {
}

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

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

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

Task {
Expand Down
10 changes: 5 additions & 5 deletions FirebaseStorage/Tests/Integration/StorageIntegration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,9 @@ class StorageResultTests: StorageIntegrationCommon {

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

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

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

ref.putData(data) { result in
switch result {
case .success:
let task = ref.write(toFile: fileURL)
task.cancel()

task.observe(StorageTaskStatus.success) { snapshot in
XCTFail("Error processing success snapshot")
Expand All @@ -603,6 +602,7 @@ class StorageResultTests: StorageIntegrationCommon {
}
expectation.fulfill()
}
task.cancel()
case let .failure(error):
XCTFail("Unexpected error \(error) from putData")
expectation.fulfill()
Expand Down
Loading