PropertyWrapperDefaultConfigs.swift 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright 2022 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. import FirebaseRemoteConfig
  17. import FirebaseRemoteConfigSwift
  18. import XCTest
  19. #if compiler(>=5.5.2) && canImport(_Concurrency)
  20. @available(iOS 14.0, macOS 11.0, macCatalyst 14.0, tvOS 14.0, watchOS 7.0, *)
  21. class PropertyWrapperDefaultConfigsTests {
  22. static let placeholderDict = ["session":"breakfast"]
  23. struct Recipe: Decodable {
  24. var recipeName: String
  25. var ingredients: [String]
  26. var cookTime: Int
  27. }
  28. static let placeholderJSON = Recipe(recipeName:"muffin", ingredients:["flour", "sugar"], cookTime:45)
  29. // MARK: - Test Remote Config default values with property wrapper
  30. struct DefaultsValuesTester {
  31. @RemoteConfigProperty(key: Constants.stringKey, placeholder: Recipe(recipeName: "test", ingredients: [], cookTime: 0))
  32. var dictValue : Recipe
  33. }
  34. func testDefaultValues() async throws {
  35. try? RemoteConfig.remoteConfig().setDefaults(from: PropertyWrapperEmptyConfigsTests.placeholderDict)
  36. let tester = await DefaultsValuesTester()
  37. let dictValue = await tester.dictValue
  38. XCTAssertEqual(dictValue.recipeName, "Flour")
  39. }
  40. }
  41. #endif