Skip to content

Commit df0718f

Browse files
authored
Core API build tests (#8352)
* Core API build tests * Fix CI
1 parent e67ae57 commit df0718f

File tree

1 file changed

+163
-0
lines changed

1 file changed

+163
-0
lines changed
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
//
2+
// Copyright 2021 Google LLC
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
// MARK: This file is used to evaluate the experience of using Firebase APIs in Swift.
18+
19+
import Foundation
20+
21+
import FirebaseCore
22+
23+
final class CoreAPITests {
24+
func usage() {
25+
// MARK: - FirebaseApp
26+
27+
// Configure Firebase app
28+
FirebaseApp.configure()
29+
30+
if let options = FirebaseOptions(contentsOfFile: "path/to/GoogleService-Info.plist") {
31+
FirebaseApp.configure(name: "App", options: options)
32+
FirebaseApp.configure(options: options)
33+
}
34+
35+
// Retrieve Firebase app(s)
36+
if let _ /* app */ = FirebaseApp.app() {
37+
// ...
38+
}
39+
40+
if let _ /* app */ = FirebaseApp.app(name: "App") {
41+
// ...
42+
}
43+
44+
if let _ /* apps */ = FirebaseApp.allApps {
45+
// ...
46+
}
47+
48+
// Delete Firebase app
49+
if let app = FirebaseApp.app() {
50+
app.delete { _ /* succes */ in
51+
// ...
52+
}
53+
}
54+
55+
#if swift(>=5.5)
56+
if #available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) {
57+
// async/await is a Swift 5.5+ feature available on iOS 15+
58+
async {
59+
do {
60+
try await app.delete()
61+
} catch {
62+
// ...
63+
}
64+
}
65+
}
66+
#endif // swift(>=5.5)
67+
68+
// Properties
69+
if let app = FirebaseApp.app() {
70+
_ = app.name
71+
_ = app.options
72+
_ = app.isDataCollectionDefaultEnabled
73+
app.isDataCollectionDefaultEnabled = false
74+
}
75+
76+
// MARK: - FirebaseConfiguration
77+
78+
_ = FirebaseConfiguration.shared
79+
FirebaseConfiguration.shared.setLoggerLevel(.debug)
80+
81+
// MARK: - FirebaseLoggerLevel
82+
83+
let loggerLevel: FirebaseLoggerLevel = .debug
84+
switch loggerLevel {
85+
case FirebaseLoggerLevel.error:
86+
break
87+
case FirebaseLoggerLevel.warning:
88+
break
89+
case FirebaseLoggerLevel.notice:
90+
break
91+
case FirebaseLoggerLevel.info:
92+
break
93+
case FirebaseLoggerLevel.debug:
94+
break
95+
default:
96+
break
97+
}
98+
99+
_ = FirebaseLoggerLevel.min
100+
_ = FirebaseLoggerLevel.max
101+
102+
// MARK: - FirebaseOptions
103+
104+
// FirebaseOptions default instance
105+
if let _ /* defaultOptions */ = FirebaseOptions.defaultOptions() {
106+
// ...
107+
}
108+
109+
// FirebaseOptions initializers
110+
_ = FirebaseOptions(googleAppID: "googleAppID", gcmSenderID: "gcmSenderID")
111+
112+
if let _ /* options */ = FirebaseOptions(contentsOfFile: "path/to/file") {
113+
// ...
114+
}
115+
116+
// Properties
117+
if let options = FirebaseOptions.defaultOptions() {
118+
_ = options.bundleID
119+
_ = options.gcmSenderID
120+
_ = options.googleAppID
121+
122+
if let _ /* apiKey */ = options.apiKey {
123+
// ...
124+
}
125+
126+
if let _ /* clientID */ = options.clientID {
127+
// ...
128+
}
129+
130+
if let _ /* trackingID */ = options.trackingID {
131+
// ...
132+
}
133+
134+
if let _ /* projectID */ = options.projectID {
135+
// ...
136+
}
137+
138+
if let _ /* androidClientID */ = options.androidClientID {
139+
// ...
140+
}
141+
142+
if let _ /* databaseURL */ = options.databaseURL {
143+
// ...
144+
}
145+
146+
if let _ /* deepLinkURLScheme */ = options.deepLinkURLScheme {
147+
// ...
148+
}
149+
150+
if let _ /* storageBucket */ = options.storageBucket {
151+
// ...
152+
}
153+
154+
if let _ /* appGroupID */ = options.appGroupID {
155+
// ...
156+
}
157+
}
158+
159+
// MARK: - FirebaseVersion
160+
161+
_ = FirebaseVersion()
162+
}
163+
}

0 commit comments

Comments
 (0)