FIRFunctionsTests.m 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2017 Google
  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 "Functions/FirebaseFunctions/FIRFunctions+Internal.h"
  16. #import "Functions/FirebaseFunctions/Public/FirebaseFunctions/FIRFunctions.h"
  17. @interface FIRFunctionsTests : XCTestCase {
  18. FIRFunctions *_functions;
  19. FIRFunctions *_functionsCustomDomain;
  20. }
  21. @end
  22. @implementation FIRFunctionsTests
  23. - (void)setUp {
  24. [super setUp];
  25. _functions = [[FIRFunctions alloc] initWithProjectID:@"my-project"
  26. region:@"my-region"
  27. customDomain:nil
  28. auth:nil
  29. messaging:nil];
  30. _functionsCustomDomain = [[FIRFunctions alloc] initWithProjectID:@"my-project"
  31. region:@"my-region"
  32. customDomain:@"https://mydomain.com"
  33. auth:nil
  34. messaging:nil];
  35. }
  36. - (void)tearDown {
  37. [super tearDown];
  38. }
  39. - (void)testURLWithName {
  40. NSString *url = [_functions URLWithName:@"my-endpoint"];
  41. XCTAssertEqualObjects(@"https://my-region-my-project.cloudfunctions.net/my-endpoint", url);
  42. }
  43. - (void)testRegionWithEmulator {
  44. [_functions useFunctionsEmulatorOrigin:@"http://localhost:5005"];
  45. NSString *url = [_functions URLWithName:@"my-endpoint"];
  46. XCTAssertEqualObjects(@"http://localhost:5005/my-project/my-region/my-endpoint", url);
  47. }
  48. - (void)testCustomDomain {
  49. NSString *url = [_functionsCustomDomain URLWithName:@"my-endpoint"];
  50. XCTAssertEqualObjects(@"https://mydomain.com/my-endpoint", url);
  51. }
  52. - (void)testCustomDomainWithEmulator {
  53. [_functionsCustomDomain useFunctionsEmulatorOrigin:@"http://localhost:5005"];
  54. NSString *url = [_functionsCustomDomain URLWithName:@"my-endpoint"];
  55. XCTAssertEqualObjects(@"http://localhost:5005/my-project/my-region/my-endpoint", url);
  56. }
  57. @end