Skip to content

Commit 2f457c2

Browse files
Port Storage Integration tests to Combine (#7959)
* Another take on verifying expected errors. (#7982) Hat tip to https://heckj.github.io/swiftui-notes/#patterns-testing-and-debugging Signed-off-by: Peter Friese <[email protected]> Co-authored-by: Peter Friese <[email protected]>
1 parent dfe6eb9 commit 2f457c2

File tree

5 files changed

+710
-5
lines changed

5 files changed

+710
-5
lines changed

.github/workflows/combine.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,27 @@ jobs:
5151

5252
- name: Build and test
5353
run: scripts/third_party/travis/retry.sh scripts/build.sh CombineSwift ${{ matrix.target }} xcodebuild
54+
55+
storage-combine-integration:
56+
# Don't run on private repo unless it is a PR.
57+
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
58+
env:
59+
plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
60+
runs-on: macos-latest
61+
steps:
62+
- uses: actions/checkout@v2
63+
- name: Setup Bundler
64+
run: scripts/setup_bundler.sh
65+
- name: Install Secret GoogleService-Info.plist
66+
run: scripts/decrypt_gha_secret.sh scripts/gha-encrypted/storage-db-plist.gpg \
67+
FirebaseStorage/Tests/Integration/Resources/GoogleService-Info.plist "$plist_secret"
68+
- name: Install Credentials.h
69+
run: scripts/decrypt_gha_secret.sh scripts/gha-encrypted/Storage/Credentials.h.gpg \
70+
FirebaseStorage/Tests/Integration/Credentials.h "$plist_secret"
71+
- name: Install Credentials.swift
72+
run: |
73+
scripts/decrypt_gha_secret.sh scripts/gha-encrypted/Storage/Credentials.swift.gpg \
74+
FirebaseStorage/Tests/SwiftIntegration/Credentials.swift "$plist_secret"
75+
cp FirebaseStorage/Tests/SwiftIntegration/Credentials.swift FirebaseStorageSwift/Tests/Integration/
76+
- name: BuildAndTest # can be replaced with pod lib lint with CocoaPods 1.10
77+
run: ([ -z $plist_secret ] || scripts/third_party/travis/retry.sh scripts/build.sh StorageCombine all)

FirebaseCombineSwift.podspec

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,23 @@ Combine Publishers for Firebase.
8282
unit_tests.dependency 'FirebaseAuthTestingSupport'
8383
unit_tests.dependency 'FirebaseFunctionsTestingSupport'
8484
end
85+
86+
s.test_spec 'integration' do |int_tests|
87+
int_tests.scheme = { :code_coverage => true }
88+
int_tests.platforms = {
89+
:ios => ios_deployment_target,
90+
:osx => osx_deployment_target,
91+
:tvos => tvos_deployment_target
92+
}
93+
int_tests.source_files = [
94+
'FirebaseCombineSwift/Tests/Integration/Storage/StorageIntegration.swift',
95+
'FirebaseStorage/Tests/SwiftIntegration/Credentials.swift'
96+
]
97+
int_tests.requires_app_host = true
98+
# Resources are shared with FirebaseStorage's integration tests.
99+
int_tests.resources = 'FirebaseStorage/Tests/Integration/Resources/1mb.dat',
100+
'FirebaseStorage/Tests/Integration/Resources/GoogleService-Info.plist',
101+
'FirebaseStorage/Tests/Integration/Resources/HomeImprovement.numbers'
102+
int_tests.dependency 'FirebaseAuth', '~> 8.0'
103+
end
85104
end

FirebaseCombineSwift/Sources/Storage/StorageReference+Combine.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
@available(swift 5.0)
2222
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
23+
2324
extension StorageReference {
2425
// MARK: - Uploads
2526

@@ -35,7 +36,7 @@
3536
/// - Returns: A publisher emitting a `StorageMetadata` instance. The publisher will emit on the *main* thread.
3637
@discardableResult
3738
public func putData(_ data: Data,
38-
metadata: StorageMetadata?) -> Future<StorageMetadata, Error> {
39+
metadata: StorageMetadata? = nil) -> Future<StorageMetadata, Error> {
3940
var task: StorageUploadTask?
4041
return Future<StorageMetadata, Error> { [weak self] promise in
4142
task = self?.putData(data, metadata: metadata) { result in
@@ -59,7 +60,7 @@
5960
/// - Returns: A publisher emitting a `StorageMetadata` instance. The publisher will emit on the *main* thread.
6061
@discardableResult
6162
public func putFile(from fileURL: URL,
62-
metadata: StorageMetadata?)
63+
metadata: StorageMetadata? = nil)
6364
-> Future<StorageMetadata, Error> {
6465
var task: StorageUploadTask?
6566
return Future<StorageMetadata, Error> { [weak self] promise in
@@ -255,13 +256,13 @@
255256
///
256257
/// - Returns: A publisher that emits whether the call was successful or not. The publisher will emit on the *main* thread.
257258
@discardableResult
258-
public func delete() -> Future<Void, Error> {
259-
Future<Void, Error> { promise in
259+
public func delete() -> Future<Bool, Error> {
260+
Future<Bool, Error> { promise in
260261
self.delete { error in
261262
if let error = error {
262263
promise(.failure(error))
263264
} else {
264-
promise(.success(()))
265+
promise(.success(true))
265266
}
266267
}
267268
}

0 commit comments

Comments
 (0)