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 async await #8289

Merged
merged 18 commits into from
Jul 23, 2021
Prev Previous commit
Next Next commit
Style and available
  • Loading branch information
paulb777 committed Jul 23, 2021
commit 6dbdd0f6693607d40f62b2fb99148ee9f6848888
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ NS_SWIFT_NAME(putData(_:metadata:));
metadata:(nullable FIRStorageMetadata *)metadata
completion:(nullable void (^)(FIRStorageMetadata *_Nullable metadata,
NSError *_Nullable error))completion
NS_SWIFT_NAME(putData(_:metadata:completion:));
NS_SWIFT_NAME(putData(_:metadata:completion:));

- (void)__putData:(NSData *)uploadData
metadata:(nullable FIRStorageMetadata *)metadata
Expand Down
8 changes: 4 additions & 4 deletions FirebaseStorageSwift/Sources/AsyncAwait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

import FirebaseStorage

@available(iOS 15.0, *)
public extension StorageReference {

@discardableResult
func putDataAwait(_ uploadData: Data,
metadata: StorageMetadata? = nil) async throws -> StorageMetadata {
// TODO: Add a parameter to capture StorageUploadTask and to enable Progress tracking.
metadata: StorageMetadata? = nil) async throws -> StorageMetadata {
// TODO: Add a parameter to capture StorageUploadTask and to enable Progress tracking.
// -> StorageUploadTask {
return try await __putDataGlue(uploadData, metadata: metadata)
return try await __putDataGlue(uploadData, metadata: metadata)
paulb777 marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class StorageAsyncAwait: StorageIntegrationCommon {
let data = try XCTUnwrap("Hello Swift World".data(using: .utf8), "Data construction failed")
let result = try await ref.putDataAwait(data, metadata: nil)
XCTAssertNotNil(result)
let _ = try await ref.delete()
_ = try await ref.delete()
}

func testDeleteWithNilCompletion() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import FirebaseStorageSwift
import XCTest

class StorageResultTests: StorageIntegrationCommon {

func testGetMetadata() {
let expectation = self.expectation(description: "testGetMetadata")
let ref = storage.reference().child("ios/public/1mb")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class StorageIntegrationCommon: XCTestCase {
}
waitForExpectations()
}

private func waitForExpectations() {
let kFIRStorageIntegrationTestTimeout = 60.0
paulb777 marked this conversation as resolved.
Show resolved Hide resolved
waitForExpectations(timeout: kFIRStorageIntegrationTestTimeout,
Expand Down