FirebaseApp+Tests.swift 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. import Foundation
  15. import FirebaseCore
  16. extension FirebaseApp {
  17. static func appOptions() -> FirebaseOptions {
  18. let options = FirebaseOptions(
  19. googleAppID: Credentials.googleAppID,
  20. gcmSenderID: Credentials.gcmSenderID
  21. )
  22. options.apiKey = Credentials.apiKey
  23. options.clientID = Credentials.clientID
  24. options.bundleID = Credentials.bundleID
  25. options.projectID = Credentials.projectID
  26. options.storageBucket = Credentials.bucket
  27. return options
  28. }
  29. static func configureForTests() {
  30. configure(options: appOptions())
  31. }
  32. static func appForAuthUnitTestsWithName(name: String) -> FirebaseApp {
  33. return FirebaseApp(instanceWithName: name, options: appOptions())
  34. }
  35. static func appForStorageUnitTestsWithName(name: String) -> FirebaseApp {
  36. let app = FirebaseApp(instanceWithName: name, options: appOptions())
  37. return app
  38. }
  39. }