ObjCAPITests.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright 2022 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 <XCTest/XCTest.h>
  15. @import FirebaseCore;
  16. @import FirebaseFunctions;
  17. @interface ObjCAPICoverage : XCTestCase
  18. @end
  19. @implementation ObjCAPICoverage
  20. - (void)apis {
  21. #pragma mark - Functions
  22. FIRApp *app = [FIRApp defaultApp];
  23. FIRFunctions *func = [FIRFunctions functions];
  24. func = [FIRFunctions functionsForApp:app];
  25. func = [FIRFunctions functionsForRegion:@"my-region"];
  26. func = [FIRFunctions functionsForCustomDomain:@"my-domain"];
  27. func = [FIRFunctions functionsForApp:app region:@"my-region"];
  28. func = [FIRFunctions functionsForApp:app customDomain:@"my-domain"];
  29. FIRHTTPSCallable *callable = [func HTTPSCallableWithName:@"name"];
  30. [func useEmulatorWithHost:@"host" port:@"port"];
  31. #pragma mark - HTTPSCallable and HTTPSCallableResult
  32. [callable
  33. callWithCompletion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) {
  34. __unused id data = result.data;
  35. }];
  36. [callable callWithObject:nil
  37. completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) {
  38. [result data];
  39. }];
  40. callable.timeoutInterval = 60;
  41. [callable timeoutInterval];
  42. }
  43. #pragma mark - FunctionsError
  44. - (FIRFunctionsErrorCode)errorCodes:(NSError *)error {
  45. switch (error.code) {
  46. case FIRFunctionsErrorCodeOK:
  47. case FIRFunctionsErrorCodeCancelled:
  48. case FIRFunctionsErrorCodeUnknown:
  49. case FIRFunctionsErrorCodeInvalidArgument:
  50. case FIRFunctionsErrorCodeDeadlineExceeded:
  51. case FIRFunctionsErrorCodeNotFound:
  52. case FIRFunctionsErrorCodeAlreadyExists:
  53. case FIRFunctionsErrorCodePermissionDenied:
  54. case FIRFunctionsErrorCodeResourceExhausted:
  55. case FIRFunctionsErrorCodeFailedPrecondition:
  56. case FIRFunctionsErrorCodeAborted:
  57. case FIRFunctionsErrorCodeOutOfRange:
  58. case FIRFunctionsErrorCodeUnimplemented:
  59. case FIRFunctionsErrorCodeInternal:
  60. case FIRFunctionsErrorCodeUnavailable:
  61. case FIRFunctionsErrorCodeDataLoss:
  62. case FIRFunctionsErrorCodeUnauthenticated:
  63. return error.code;
  64. }
  65. }
  66. @end