FIRCLSReportUploaderTests.m 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Copyright 2019 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 "FIRCLSReportUploader_Private.h"
  16. #import "FABMockApplicationIdentifierModel.h"
  17. #import "FIRCLSApplication.h"
  18. #include "FIRCLSConstants.h"
  19. #include "FIRCLSDefines.h"
  20. #include "FIRCLSFileManager.h"
  21. #include "FIRCLSMockSettings.h"
  22. #include "FIRCLSSettings.h"
  23. NSString *const TestEndpoint = @"https://reports.crashlytics.com";
  24. @interface FIRCLSReportUploaderTests
  25. : XCTestCase <FIRCLSReportUploaderDelegate, FIRCLSReportUploaderDataSource>
  26. @property(nonatomic, strong) FIRCLSReportUploader *uploader;
  27. @property(nonatomic, strong) FIRCLSFileManager *fileManager;
  28. @property(nonatomic, strong) NSOperationQueue *queue;
  29. @property(nonatomic, strong) NSURL *url;
  30. @end
  31. @implementation FIRCLSReportUploaderTests
  32. - (void)setUp {
  33. [super setUp];
  34. self.queue = [NSOperationQueue new];
  35. self.fileManager = [[FIRCLSFileManager alloc] init];
  36. self.uploader = [[FIRCLSReportUploader alloc] initWithQueue:self.queue
  37. delegate:self
  38. dataSource:self
  39. client:nil
  40. fileManager:nil
  41. analytics:nil];
  42. // glue together a string that will work for both platforms
  43. NSString *urlString =
  44. [NSString stringWithFormat:@"%@/sdk-api/v1/platforms/%@/apps/%@/reports", TestEndpoint,
  45. FIRCLSApplicationGetPlatform(), self.bundleIdentifier];
  46. self.url = [NSURL URLWithString:urlString];
  47. }
  48. - (void)tearDown {
  49. self.uploader = nil;
  50. [super tearDown];
  51. }
  52. - (void)testURLGeneration {
  53. XCTAssertEqualObjects([self.uploader reportURL], _url);
  54. }
  55. #pragma mark - FIRCLSReportUploaderDelegate
  56. - (void)didCompletePackageSubmission:(NSString *)path
  57. dataCollectionToken:(FIRCLSDataCollectionToken *)token
  58. error:(NSError *)error {
  59. }
  60. - (NSString *)bundleIdentifier {
  61. return @"com.test.TestApp";
  62. }
  63. - (NSString *)googleAppID {
  64. return @"someGoogleAppId";
  65. }
  66. - (FIRCLSSettings *)settings {
  67. FABMockApplicationIdentifierModel *appIDModel = [[FABMockApplicationIdentifierModel alloc] init];
  68. FIRCLSMockSettings *settings = [[FIRCLSMockSettings alloc] initWithFileManager:self.fileManager
  69. appIDModel:appIDModel];
  70. settings.fetchedBundleID = self.bundleIdentifier;
  71. return settings;
  72. }
  73. - (void)didCompleteAllSubmissions {
  74. }
  75. @end