FIRCLSFileManagerTests.m 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 <Foundation/Foundation.h>
  15. #import <XCTest/XCTest.h>
  16. #import "Crashlytics/Crashlytics/Models/FIRCLSFileManager.h"
  17. @interface FIRCLSFileManagerTests : XCTestCase {
  18. FIRCLSFileManager* _manager;
  19. }
  20. @property(nonatomic, retain, readonly) FIRCLSFileManager* manager;
  21. @end
  22. @implementation FIRCLSFileManagerTests
  23. - (void)setUp {
  24. [super setUp];
  25. _manager = [[FIRCLSFileManager alloc] init];
  26. [self removeRootDirectory];
  27. }
  28. - (void)tearDown {
  29. [self removeRootDirectory];
  30. [super tearDown];
  31. }
  32. - (BOOL)removeRootDirectory {
  33. if ([self doesFileExist:[_manager rootPath]]) {
  34. assert([_manager removeItemAtPath:[_manager rootPath]]);
  35. }
  36. return YES;
  37. }
  38. - (void)printPathContents:(NSString*)path {
  39. NSLog(@"%@", [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil]);
  40. }
  41. - (BOOL)doesFileExist:(NSString*)path {
  42. return [[NSFileManager defaultManager] fileExistsAtPath:path];
  43. }
  44. - (void)testCreateV4DirectoryStructure {
  45. NSString* path = [[self manager] rootPath];
  46. [[self manager] createReportDirectories];
  47. XCTAssertTrue([self doesFileExist:path], @"");
  48. path = [path stringByAppendingPathComponent:@"v5/reports"];
  49. XCTAssertTrue([self doesFileExist:path], @"");
  50. for (NSString* subpath in @[ @"active", @"prepared", @"processing" ]) {
  51. XCTAssertTrue([self doesFileExist:[path stringByAppendingPathComponent:subpath]], @"");
  52. }
  53. }
  54. @end