aboutsummaryrefslogtreecommitdiffhomepage
path: root/Example
diff options
context:
space:
mode:
authorGravatar Sebastian Schmidt <mrschmidt@google.com>2017-11-09 14:43:53 -0800
committerGravatar Sebastian Schmidt <mrschmidt@google.com>2017-11-09 17:51:21 -0800
commit110f0edf9d25887984fcdf12becb11a4661ad637 (patch)
treeb65ffc470b32e1142ad42e016bfc18bae49722bf /Example
parent86f429b2f0061a9f16c42f83841d36813892232b (diff)
Clang-formatting Storage
Diffstat (limited to 'Example')
-rw-r--r--Example/Storage/App/iOS/FIRAppDelegate.h2
-rw-r--r--Example/Storage/App/iOS/FIRAppDelegate.m45
-rw-r--r--Example/Storage/App/iOS/FIRViewController.m14
-rw-r--r--Example/Storage/App/iOS/main.m9
-rw-r--r--Example/Storage/App/macOS/FIRAppDelegate.h2
-rw-r--r--Example/Storage/App/macOS/FIRAppDelegate.m6
-rw-r--r--Example/Storage/App/macOS/FIRViewController.h2
-rw-r--r--Example/Storage/App/macOS/FIRViewController.m10
-rw-r--r--Example/Storage/App/macOS/main.m4
-rw-r--r--Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m652
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageDeleteTests.m56
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageGetMetadataTests.m11
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageMetadataTests.m26
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageTestHelpers.m11
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageTests.m21
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageTokenAuthorizerTests.m124
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageUpdateMetadataTests.m35
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageUtilsTests.m8
18 files changed, 512 insertions, 526 deletions
diff --git a/Example/Storage/App/iOS/FIRAppDelegate.h b/Example/Storage/App/iOS/FIRAppDelegate.h
index e3fba8f..1eb5040 100644
--- a/Example/Storage/App/iOS/FIRAppDelegate.h
+++ b/Example/Storage/App/iOS/FIRAppDelegate.h
@@ -18,6 +18,6 @@
@interface FIRAppDelegate : UIResponder <UIApplicationDelegate>
-@property (strong, nonatomic) UIWindow *window;
+@property(strong, nonatomic) UIWindow *window;
@end
diff --git a/Example/Storage/App/iOS/FIRAppDelegate.m b/Example/Storage/App/iOS/FIRAppDelegate.m
index 0ecfdea..9568d06 100644
--- a/Example/Storage/App/iOS/FIRAppDelegate.m
+++ b/Example/Storage/App/iOS/FIRAppDelegate.m
@@ -16,37 +16,40 @@
@implementation FIRAppDelegate
-- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
-{
- // Override point for customization after application launch.
- return YES;
+- (BOOL)application:(UIApplication *)application
+ didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+ // Override point for customization after application launch.
+ return YES;
}
-- (void)applicationWillResignActive:(UIApplication *)application
-{
- // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
- // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+- (void)applicationWillResignActive:(UIApplication *)application {
+ // Sent when the application is about to move from active to inactive state. This can occur for
+ // certain types of temporary interruptions (such as an incoming phone call or SMS message) or
+ // when the user quits the application and it begins the transition to the background state. Use
+ // this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates.
+ // Games should use this method to pause the game.
}
-- (void)applicationDidEnterBackground:(UIApplication *)application
-{
- // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
- // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+- (void)applicationDidEnterBackground:(UIApplication *)application {
+ // Use this method to release shared resources, save user data, invalidate timers, and store
+ // enough application state information to restore your application to its current state in case
+ // it is terminated later. If your application supports background execution, this method is
+ // called instead of applicationWillTerminate: when the user quits.
}
-- (void)applicationWillEnterForeground:(UIApplication *)application
-{
- // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+- (void)applicationWillEnterForeground:(UIApplication *)application {
+ // Called as part of the transition from the background to the inactive state; here you can undo
+ // many of the changes made on entering the background.
}
-- (void)applicationDidBecomeActive:(UIApplication *)application
-{
- // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+- (void)applicationDidBecomeActive:(UIApplication *)application {
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If
+ // the application was previously in the background, optionally refresh the user interface.
}
-- (void)applicationWillTerminate:(UIApplication *)application
-{
- // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+- (void)applicationWillTerminate:(UIApplication *)application {
+ // Called when the application is about to terminate. Save data if appropriate. See also
+ // applicationDidEnterBackground:.
}
@end
diff --git a/Example/Storage/App/iOS/FIRViewController.m b/Example/Storage/App/iOS/FIRViewController.m
index 901accf..027aabf 100644
--- a/Example/Storage/App/iOS/FIRViewController.m
+++ b/Example/Storage/App/iOS/FIRViewController.m
@@ -20,16 +20,14 @@
@implementation FIRViewController
-- (void)viewDidLoad
-{
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ // Do any additional setup after loading the view, typically from a nib.
}
-- (void)didReceiveMemoryWarning
-{
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
+- (void)didReceiveMemoryWarning {
+ [super didReceiveMemoryWarning];
+ // Dispose of any resources that can be recreated.
}
@end
diff --git a/Example/Storage/App/iOS/main.m b/Example/Storage/App/iOS/main.m
index 03b5c12..39c05a5 100644
--- a/Example/Storage/App/iOS/main.m
+++ b/Example/Storage/App/iOS/main.m
@@ -15,9 +15,8 @@
@import UIKit;
#import "FIRAppDelegate.h"
-int main(int argc, char * argv[])
-{
- @autoreleasepool {
- return UIApplicationMain(argc, argv, nil, NSStringFromClass([FIRAppDelegate class]));
- }
+int main(int argc, char* argv[]) {
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([FIRAppDelegate class]));
+ }
}
diff --git a/Example/Storage/App/macOS/FIRAppDelegate.h b/Example/Storage/App/macOS/FIRAppDelegate.h
index e637ef9..96400bd 100644
--- a/Example/Storage/App/macOS/FIRAppDelegate.h
+++ b/Example/Storage/App/macOS/FIRAppDelegate.h
@@ -18,6 +18,4 @@
@interface FIRAppDelegate : NSObject <NSApplicationDelegate>
-
@end
-
diff --git a/Example/Storage/App/macOS/FIRAppDelegate.m b/Example/Storage/App/macOS/FIRAppDelegate.m
index 9a363a6..1eb675e 100644
--- a/Example/Storage/App/macOS/FIRAppDelegate.m
+++ b/Example/Storage/App/macOS/FIRAppDelegate.m
@@ -23,13 +23,11 @@
@implementation FIRAppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
- // Insert code here to initialize your application
+ // Insert code here to initialize your application
}
-
- (void)applicationWillTerminate:(NSNotification *)aNotification {
- // Insert code here to tear down your application
+ // Insert code here to tear down your application
}
-
@end
diff --git a/Example/Storage/App/macOS/FIRViewController.h b/Example/Storage/App/macOS/FIRViewController.h
index efee5d5..72497a3 100644
--- a/Example/Storage/App/macOS/FIRViewController.h
+++ b/Example/Storage/App/macOS/FIRViewController.h
@@ -18,6 +18,4 @@
@interface FIRViewController : NSViewController
-
@end
-
diff --git a/Example/Storage/App/macOS/FIRViewController.m b/Example/Storage/App/macOS/FIRViewController.m
index 08c5bb5..616257f 100644
--- a/Example/Storage/App/macOS/FIRViewController.m
+++ b/Example/Storage/App/macOS/FIRViewController.m
@@ -19,17 +19,15 @@
@implementation FIRViewController
- (void)viewDidLoad {
- [super viewDidLoad];
+ [super viewDidLoad];
- // Do any additional setup after loading the view.
+ // Do any additional setup after loading the view.
}
-
- (void)setRepresentedObject:(id)representedObject {
- [super setRepresentedObject:representedObject];
+ [super setRepresentedObject:representedObject];
- // Update the view, if already loaded.
+ // Update the view, if already loaded.
}
-
@end
diff --git a/Example/Storage/App/macOS/main.m b/Example/Storage/App/macOS/main.m
index e8858a6..45ed70f 100644
--- a/Example/Storage/App/macOS/main.m
+++ b/Example/Storage/App/macOS/main.m
@@ -16,6 +16,6 @@
#import <Cocoa/Cocoa.h>
-int main(int argc, const char * argv[]) {
- return NSApplicationMain(argc, argv);
+int main(int argc, const char* argv[]) {
+ return NSApplicationMain(argc, argv);
}
diff --git a/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m b/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m
index 0e07d97..8c7f972 100644
--- a/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m
+++ b/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#import <math.h>
#import <XCTest/XCTest.h>
+#import <math.h>
#import "FirebaseStorage.h"
@@ -56,427 +56,428 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
@implementation FIRStorageIntegrationTests
-
+ (void)setUp {
- [FIRApp configure];
+ [FIRApp configure];
}
- (void)setUp {
- [super setUp];
+ [super setUp];
- self.app = [FIRApp defaultApp];
- self.storage = [FIRStorage storageForApp:self.app];
+ self.app = [FIRApp defaultApp];
+ self.storage = [FIRStorage storageForApp:self.app];
- static dispatch_once_t once;
- dispatch_once(&once, ^{
- XCTestExpectation *expectation = [self expectationWithDescription:@"setup"];
+ static dispatch_once_t once;
+ dispatch_once(&once, ^{
+ XCTestExpectation *expectation = [self expectationWithDescription:@"setup"];
- FIRStorageReference *ref = [[FIRStorage storage].reference child:@"ios/public/1mb"];
- NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"1mb" ofType:@"dat"]];
- XCTAssertNotNil(data, "Could not load bundled file");
- [ref putData:data metadata:nil completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNil(error);
- [expectation fulfill];
+ FIRStorageReference *ref = [[FIRStorage storage].reference child:@"ios/public/1mb"];
+ NSData *data = [NSData
+ dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"1mb" ofType:@"dat"]];
+ XCTAssertNotNil(data, "Could not load bundled file");
+ [ref putData:data
+ metadata:nil
+ completion:^(FIRStorageMetadata *metadata, NSError *error) {
+ XCTAssertNil(error);
+ [expectation fulfill];
}];
- [self waitForExpectations];
- });
+ [self waitForExpectations];
+ });
}
- (void)tearDown {
- self.app = nil;
- self.storage = nil;
+ self.app = nil;
+ self.storage = nil;
- [super tearDown];
+ [super tearDown];
}
- (void)testName {
- NSString *aGSURI = [NSString stringWithFormat:@"gs://%@.appspot.com/path/to", [[FIRApp defaultApp] options].projectID];
- FIRStorageReference *ref = [self.storage referenceForURL:aGSURI];
- XCTAssertEqualObjects(ref.description, aGSURI);
+ NSString *aGSURI = [NSString
+ stringWithFormat:@"gs://%@.appspot.com/path/to", [[FIRApp defaultApp] options].projectID];
+ FIRStorageReference *ref = [self.storage referenceForURL:aGSURI];
+ XCTAssertEqualObjects(ref.description, aGSURI);
}
- (void)testUnauthenticatedGetMetadata {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedGetMetadata"];
- FIRStorageReference *ref = [self.storage.reference child:@"ios/public/1mb"];
+ FIRStorageReference *ref = [self.storage.reference child:@"ios/public/1mb"];
- [ref metadataWithCompletion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
- }];
+ [ref metadataWithCompletion:^(FIRStorageMetadata *metadata, NSError *error) {
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [expectation fulfill];
+ }];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedUpdateMetadata {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedUpdateMetadata"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
-
- FIRStorageMetadata *meta = [[FIRStorageMetadata alloc] init];
- [meta setContentType:@"lol/custom"];
- [meta setCustomMetadata:@{
- @"lol" : @"custom metadata is neat",
- @"ちかてつ" : @"🚇",
- @"shinkansen" : @"新幹線"
- }];
-
- [ref updateMetadata:meta
- completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertEqualObjects(meta.contentType, metadata.contentType);
- XCTAssertEqualObjects(meta.customMetadata[@"lol"],
- metadata.customMetadata[@"lol"]);
- XCTAssertEqualObjects(meta.customMetadata[@"ちかてつ"],
- metadata.customMetadata[@"ちかてつ"]);
- XCTAssertEqualObjects(meta.customMetadata[@"shinkansen"],
- metadata.customMetadata[@"shinkansen"]);
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
- }];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
+
+ FIRStorageMetadata *meta = [[FIRStorageMetadata alloc] init];
+ [meta setContentType:@"lol/custom"];
+ [meta setCustomMetadata:@{
+ @"lol" : @"custom metadata is neat",
+ @"ちかてつ" : @"🚇",
+ @"shinkansen" : @"新幹線"
+ }];
+
+ [ref updateMetadata:meta
+ completion:^(FIRStorageMetadata *metadata, NSError *error) {
+ XCTAssertEqualObjects(meta.contentType, metadata.contentType);
+ XCTAssertEqualObjects(meta.customMetadata[@"lol"], metadata.customMetadata[@"lol"]);
+ XCTAssertEqualObjects(meta.customMetadata[@"ちかてつ"],
+ metadata.customMetadata[@"ちかてつ"]);
+ XCTAssertEqualObjects(meta.customMetadata[@"shinkansen"],
+ metadata.customMetadata[@"shinkansen"]);
+ XCTAssertNil(error, "Error should be nil");
+ [expectation fulfill];
+ }];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedDelete {
- XCTestExpectation *expectation = [self expectationWithDescription:@"testUnauthenticatedDelete"];
+ XCTestExpectation *expectation = [self expectationWithDescription:@"testUnauthenticatedDelete"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/fileToDelete"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/fileToDelete"];
- NSData *data = [@"Delete me!!!!!!!" dataUsingEncoding:NSUTF8StringEncoding];
+ NSData *data = [@"Delete me!!!!!!!" dataUsingEncoding:NSUTF8StringEncoding];
- [ref putData:data
+ [ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [ref deleteWithCompletion:^(NSError *error) {
XCTAssertNil(error, "Error should be nil");
- [ref deleteWithCompletion:^(NSError *error) {
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
- }];
+ [expectation fulfill];
+ }];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testDeleteWithNilCompletion {
- XCTestExpectation *expectation = [self expectationWithDescription:@"testDeleteWithNilCompletion"];
+ XCTestExpectation *expectation = [self expectationWithDescription:@"testDeleteWithNilCompletion"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/fileToDelete"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/fileToDelete"];
- NSData *data = [@"Delete me!!!!!!!" dataUsingEncoding:NSUTF8StringEncoding];
+ NSData *data = [@"Delete me!!!!!!!" dataUsingEncoding:NSUTF8StringEncoding];
- [ref putData:data
+ [ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- [ref deleteWithCompletion:nil];
- [expectation fulfill];
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [ref deleteWithCompletion:nil];
+ [expectation fulfill];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutData {
- XCTestExpectation *expectation =
- [self expectationWithDescription:@"testUnauthenticatedSimplePutData"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/testBytesUpload"];
+ XCTestExpectation *expectation =
+ [self expectationWithDescription:@"testUnauthenticatedSimplePutData"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/testBytesUpload"];
- NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
+ NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
- [ref putData:data
+ [ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [expectation fulfill];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutEmptyData {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutEmptyData"];
- FIRStorageReference *ref =
+ FIRStorageReference *ref =
[self.storage referenceWithPath:@"ios/public/testUnauthenticatedSimplePutEmptyData"];
- NSData *data = [[NSData alloc] init];
+ NSData *data = [[NSData alloc] init];
- [ref putData:data
+ [ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [expectation fulfill];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutDataUnauthorized {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutDataUnauthorized"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/private/secretfile.txt"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/private/secretfile.txt"];
- NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
+ NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
- [ref putData:data
+ [ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNil(metadata, "Metadata should be nil");
- XCTAssertNotNil(error, "Error should not be nil");
- XCTAssertEqual(error.code, FIRStorageErrorCodeUnauthorized);
- [expectation fulfill];
+ XCTAssertNil(metadata, "Metadata should be nil");
+ XCTAssertNotNil(error, "Error should not be nil");
+ XCTAssertEqual(error.code, FIRStorageErrorCodeUnauthorized);
+ [expectation fulfill];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutFile {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutFile"];
- FIRStorageReference *ref =
+ FIRStorageReference *ref =
[self.storage referenceWithPath:@"ios/public/testUnauthenticatedSimplePutFile"];
- NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
- NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
- NSURL *fileURL =
- [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"txt"];
- [data writeToURL:fileURL atomically:YES];
-
- FIRStorageUploadTask *task = [ref putFile:fileURL
- metadata:nil
- completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- }];
-
- __block long uploadedBytes = -1;
-
- [task observeStatus:FIRStorageTaskStatusSuccess
- handler:^(FIRStorageTaskSnapshot *snapshot) {
- XCTAssertEqualObjects([snapshot description], @"<State: Success>");
- [expectation fulfill];
- }];
-
- [task observeStatus:FIRStorageTaskStatusProgress
- handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
- XCTAssertTrue([[snapshot description] containsString:@"State: Progress"] ||
- [[snapshot description] containsString:@"State: Resume"]);
- NSProgress *progress = snapshot.progress;
- XCTAssertGreaterThanOrEqual(progress.completedUnitCount, uploadedBytes);
- uploadedBytes = progress.completedUnitCount;
- }];
+ NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
+ NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
+ NSURL *fileURL =
+ [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"txt"];
+ [data writeToURL:fileURL atomically:YES];
- [self waitForExpectations];
+ FIRStorageUploadTask *task = [ref putFile:fileURL
+ metadata:nil
+ completion:^(FIRStorageMetadata *metadata, NSError *error) {
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ }];
+
+ __block long uploadedBytes = -1;
+
+ [task observeStatus:FIRStorageTaskStatusSuccess
+ handler:^(FIRStorageTaskSnapshot *snapshot) {
+ XCTAssertEqualObjects([snapshot description], @"<State: Success>");
+ [expectation fulfill];
+ }];
+
+ [task observeStatus:FIRStorageTaskStatusProgress
+ handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
+ XCTAssertTrue([[snapshot description] containsString:@"State: Progress"] ||
+ [[snapshot description] containsString:@"State: Resume"]);
+ NSProgress *progress = snapshot.progress;
+ XCTAssertGreaterThanOrEqual(progress.completedUnitCount, uploadedBytes);
+ uploadedBytes = progress.completedUnitCount;
+ }];
+
+ [self waitForExpectations];
}
- (void)testPutFileWithSpecialCharacters {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testPutFileWithSpecialCharacters"];
- NSString *fileName = @"hello&+@_ .txt";
- FIRStorageReference *ref =
- [self.storage referenceWithPath:[@"ios/public/" stringByAppendingString:fileName]];
+ NSString *fileName = @"hello&+@_ .txt";
+ FIRStorageReference *ref =
+ [self.storage referenceWithPath:[@"ios/public/" stringByAppendingString:fileName]];
- NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
- NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
- NSURL *fileURL = [tmpDirURL URLByAppendingPathComponent:fileName];
- [data writeToURL:fileURL atomically:YES];
+ NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
+ NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
+ NSURL *fileURL = [tmpDirURL URLByAppendingPathComponent:fileName];
+ [data writeToURL:fileURL atomically:YES];
- [ref putFile:fileURL
+ [ref putFile:fileURL
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ XCTAssertEqualObjects(fileName, metadata.name);
+ FIRStorageReference *download =
+ [self.storage referenceWithPath:[@"ios/public/" stringByAppendingString:fileName]];
+ [download metadataWithCompletion:^(FIRStorageMetadata *metadata, NSError *error) {
XCTAssertNotNil(metadata, "Metadata should not be nil");
XCTAssertNil(error, "Error should be nil");
XCTAssertEqualObjects(fileName, metadata.name);
- FIRStorageReference *download =
- [self.storage referenceWithPath:[@"ios/public/" stringByAppendingString:fileName]];
- [download metadataWithCompletion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- XCTAssertEqualObjects(fileName, metadata.name);
- [expectation fulfill];
- }];
+ [expectation fulfill];
+ }];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutDataNoMetadata {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutDataNoMetadata"];
- FIRStorageReference *ref =
+ FIRStorageReference *ref =
[self.storage referenceWithPath:@"ios/public/testUnauthenticatedSimplePutDataNoMetadata"];
- NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
+ NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
- [ref putData:data
+ [ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [expectation fulfill];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutFileNoMetadata {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutFileNoMetadata"];
- FIRStorageReference *ref =
+ FIRStorageReference *ref =
[self.storage referenceWithPath:@"ios/public/testUnauthenticatedSimplePutFileNoMetadata"];
- NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
- NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
- NSURL *fileURL =
- [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"txt"];
- [data writeToURL:fileURL atomically:YES];
+ NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
+ NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
+ NSURL *fileURL =
+ [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"txt"];
+ [data writeToURL:fileURL atomically:YES];
- [ref putFile:fileURL
+ [ref putFile:fileURL
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [expectation fulfill];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimpleGetData {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimpleGetData"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
- [ref dataWithMaxSize:1 * 1024 * 1024
- completion:^(NSData *data, NSError *error) {
- XCTAssertNotNil(data, "Data should not be nil");
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
- }];
+ [ref dataWithMaxSize:1 * 1024 * 1024
+ completion:^(NSData *data, NSError *error) {
+ XCTAssertNotNil(data, "Data should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [expectation fulfill];
+ }];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimpleGetDataTooSmall {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimpleGetDataTooSmall"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
- /// Only allow 1kB size, which is smaller than our file
- [ref dataWithMaxSize:1 * 1024
- completion:^(NSData *data, NSError *error) {
- XCTAssertEqual(data, nil);
- XCTAssertEqual(error.code, FIRStorageErrorCodeDownloadSizeExceeded);
- [expectation fulfill];
- }];
+ /// Only allow 1kB size, which is smaller than our file
+ [ref dataWithMaxSize:1 * 1024
+ completion:^(NSData *data, NSError *error) {
+ XCTAssertEqual(data, nil);
+ XCTAssertEqual(error.code, FIRStorageErrorCodeDownloadSizeExceeded);
+ [expectation fulfill];
+ }];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimpleGetFile {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimpleGetData"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/helloworld"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/helloworld"];
- NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
- NSURL *fileURL =
+ NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
+ NSURL *fileURL =
[[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"txt"];
- [ref putData:[@"Hello World" dataUsingEncoding:NSUTF8StringEncoding] metadata:nil
- completion:^(FIRStorageMetadata *metadata, NSError *error)
- {
+ [ref putData:[@"Hello World" dataUsingEncoding:NSUTF8StringEncoding]
+ metadata:nil
+ completion:^(FIRStorageMetadata *metadata, NSError *error) {
FIRStorageDownloadTask *task = [ref writeToFile:fileURL];
[task observeStatus:FIRStorageTaskStatusSuccess
handler:^(FIRStorageTaskSnapshot *snapshot) {
- NSString *data = [NSString stringWithContentsOfURL:fileURL
- encoding:NSUTF8StringEncoding
- error:NULL];
- NSString *expectedData = @"Hello World";
- XCTAssertEqualObjects(data, expectedData);
- XCTAssertEqualObjects([snapshot description], @"<State: Success>");
- [expectation fulfill];
+ NSString *data = [NSString stringWithContentsOfURL:fileURL
+ encoding:NSUTF8StringEncoding
+ error:NULL];
+ NSString *expectedData = @"Hello World";
+ XCTAssertEqualObjects(data, expectedData);
+ XCTAssertEqualObjects([snapshot description], @"<State: Success>");
+ [expectation fulfill];
}];
[task observeStatus:FIRStorageTaskStatusProgress
handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
- NSProgress *progress = snapshot.progress;
- NSLog(@"%lld of %lld", progress.completedUnitCount, progress.totalUnitCount);
+ NSProgress *progress = snapshot.progress;
+ NSLog(@"%lld of %lld", progress.completedUnitCount, progress.totalUnitCount);
}];
[task observeStatus:FIRStorageTaskStatusFailure
handler:^(FIRStorageTaskSnapshot *snapshot) {
- XCTAssertNil(snapshot.error);
- [expectation fulfill];
+ XCTAssertNil(snapshot.error);
+ [expectation fulfill];
}];
- }];
+ }];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testCancelDownload {
- XCTestExpectation *expectation =
- [self expectationWithDescription:@"testCancelDownload"];
+ XCTestExpectation *expectation = [self expectationWithDescription:@"testCancelDownload"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
- NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
- NSURL *fileURL =
- [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"dat"];
+ NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
+ NSURL *fileURL =
+ [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"dat"];
- FIRStorageDownloadTask *task = [ref writeToFile:fileURL];
+ FIRStorageDownloadTask *task = [ref writeToFile:fileURL];
- [task observeStatus:FIRStorageTaskStatusFailure
- handler:^(FIRStorageTaskSnapshot *snapshot) {
- XCTAssertTrue([[snapshot description] containsString:@"State: Failed"]);
- [expectation fulfill];
- }];
+ [task observeStatus:FIRStorageTaskStatusFailure
+ handler:^(FIRStorageTaskSnapshot *snapshot) {
+ XCTAssertTrue([[snapshot description] containsString:@"State: Failed"]);
+ [expectation fulfill];
+ }];
- [task observeStatus:FIRStorageTaskStatusProgress
- handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
- [task cancel];
- }];
+ [task observeStatus:FIRStorageTaskStatusProgress
+ handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
+ [task cancel];
+ }];
- [self waitForExpectations];
+ [self waitForExpectations];
}
-- (void)assertMetadata:(FIRStorageMetadata *) actualMetadata
- contentType:(NSString *) expectedContentType
- customMetadata:(NSDictionary *) expectedCustomMetadata {
+- (void)assertMetadata:(FIRStorageMetadata *)actualMetadata
+ contentType:(NSString *)expectedContentType
+ customMetadata:(NSDictionary *)expectedCustomMetadata {
XCTAssertEqualObjects(actualMetadata.cacheControl, @"cache-control");
XCTAssertEqualObjects(actualMetadata.contentDisposition, @"content-disposition");
XCTAssertEqualObjects(actualMetadata.contentEncoding, @"gzip");
XCTAssertEqualObjects(actualMetadata.contentLanguage, @"de");
XCTAssertEqualObjects(actualMetadata.contentType, expectedContentType);
- for (NSString* key in expectedCustomMetadata) {
+ for (NSString *key in expectedCustomMetadata) {
XCTAssertEqualObjects([actualMetadata.customMetadata objectForKey:key],
[expectedCustomMetadata objectForKey:key]);
}
}
-- (void)assertMetadataNil:(FIRStorageMetadata *) actualMetadata {
- XCTAssertNil(actualMetadata.cacheControl);
- XCTAssertNil(actualMetadata.contentDisposition);
- XCTAssertEqualObjects(actualMetadata.contentEncoding, @"identity");
- XCTAssertNil(actualMetadata.contentLanguage);
- XCTAssertNil(actualMetadata.contentType);
- XCTAssertNil([actualMetadata.customMetadata objectForKey:@"a"]);
- XCTAssertNil([actualMetadata.customMetadata objectForKey:@"c"]);
- XCTAssertNil([actualMetadata.customMetadata objectForKey:@"f"]);
+- (void)assertMetadataNil:(FIRStorageMetadata *)actualMetadata {
+ XCTAssertNil(actualMetadata.cacheControl);
+ XCTAssertNil(actualMetadata.contentDisposition);
+ XCTAssertEqualObjects(actualMetadata.contentEncoding, @"identity");
+ XCTAssertNil(actualMetadata.contentLanguage);
+ XCTAssertNil(actualMetadata.contentType);
+ XCTAssertNil([actualMetadata.customMetadata objectForKey:@"a"]);
+ XCTAssertNil([actualMetadata.customMetadata objectForKey:@"c"]);
+ XCTAssertNil([actualMetadata.customMetadata objectForKey:@"f"]);
}
- (void)testUpdateMetadata {
@@ -493,100 +494,107 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
metadata.contentType = @"content-type-a";
metadata.customMetadata = @{@"a" : @"b"};
- [ref updateMetadata:metadata completion:^(FIRStorageMetadata *updatedMetadata, NSError *error) {
- XCTAssertNil(error);
- [self assertMetadata:updatedMetadata contentType:@"content-type-a" customMetadata:@{@"a" : @"b"}];
-
- // Update a subset of the metadata using the existing object.
- FIRStorageMetadata *metadata = updatedMetadata;
- metadata.contentType = @"content-type-b";
- metadata.customMetadata = @{@"a" : @"b", @"c" : @"d"};
-
- [ref updateMetadata:metadata completion:^(FIRStorageMetadata *updatedMetadata, NSError *error) {
- XCTAssertNil(error);
- [self assertMetadata:updatedMetadata contentType:@"content-type-b" customMetadata: @{@"a" : @"b", @"c" : @"d"}];
-
- // Clear all metadata.
- FIRStorageMetadata *metadata = updatedMetadata;
- metadata.cacheControl = nil;
- metadata.contentDisposition = nil;
- metadata.contentEncoding = nil;
- metadata.contentLanguage = nil;
- metadata.contentType = nil;
- metadata.customMetadata = [NSDictionary dictionary];
-
- [ref updateMetadata:metadata completion:^(FIRStorageMetadata *updatedMetadata, NSError *error) {
- XCTAssertNil(error);
- [self assertMetadataNil:updatedMetadata];
- [expectation fulfill];
- }];
- }];
- }];
+ [ref updateMetadata:metadata
+ completion:^(FIRStorageMetadata *updatedMetadata, NSError *error) {
+ XCTAssertNil(error);
+ [self assertMetadata:updatedMetadata
+ contentType:@"content-type-a"
+ customMetadata:@{@"a" : @"b"}];
+
+ // Update a subset of the metadata using the existing object.
+ FIRStorageMetadata *metadata = updatedMetadata;
+ metadata.contentType = @"content-type-b";
+ metadata.customMetadata = @{@"a" : @"b", @"c" : @"d"};
+
+ [ref updateMetadata:metadata
+ completion:^(FIRStorageMetadata *updatedMetadata, NSError *error) {
+ XCTAssertNil(error);
+ [self assertMetadata:updatedMetadata
+ contentType:@"content-type-b"
+ customMetadata:@{@"a" : @"b", @"c" : @"d"}];
+
+ // Clear all metadata.
+ FIRStorageMetadata *metadata = updatedMetadata;
+ metadata.cacheControl = nil;
+ metadata.contentDisposition = nil;
+ metadata.contentEncoding = nil;
+ metadata.contentLanguage = nil;
+ metadata.contentType = nil;
+ metadata.customMetadata = [NSDictionary dictionary];
+
+ [ref updateMetadata:metadata
+ completion:^(FIRStorageMetadata *updatedMetadata, NSError *error) {
+ XCTAssertNil(error);
+ [self assertMetadataNil:updatedMetadata];
+ [expectation fulfill];
+ }];
+ }];
+ }];
[self waitForExpectations];
}
- (void)testUnauthenticatedResumeGetFile {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedResumeGetFile"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
-
- NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
- NSURL *fileURL =
- [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"txt"];
-
- __block long resumeAtBytes = 256 * 1024;
- __block long downloadedBytes = 0;
- __block double computationResult = 0;
-
- FIRStorageDownloadTask *task = [ref writeToFile:fileURL];
-
- [task observeStatus:FIRStorageTaskStatusSuccess
- handler:^(FIRStorageTaskSnapshot *snapshot) {
- XCTAssertEqualObjects([snapshot description], @"<State: Success>");
- [expectation fulfill];
- }];
-
- [task observeStatus:FIRStorageTaskStatusProgress
- handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
- XCTAssertTrue([[snapshot description] containsString:@"State: Progress"] ||
- [[snapshot description] containsString:@"State: Resume"]);
- NSProgress *progress = snapshot.progress;
- XCTAssertGreaterThanOrEqual(progress.completedUnitCount, downloadedBytes);
- downloadedBytes = progress.completedUnitCount;
- if (progress.completedUnitCount > resumeAtBytes) {
- // Making sure the main run loop is busy.
- for (int i = 0; i < 500; ++i) {
- dispatch_async(dispatch_get_main_queue(), ^ {
- computationResult = sqrt(INT_MAX - i);
- });
- }
- NSLog(@"Pausing");
- [task pause];
- resumeAtBytes = INT_MAX;
- }
- }];
-
- [task observeStatus:FIRStorageTaskStatusPause
- handler:^(FIRStorageTaskSnapshot *snapshot) {
- XCTAssertEqualObjects([snapshot description], @"<State: Paused>");
- NSLog(@"Resuming");
- [task resume];
- }];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
- [self waitForExpectations];
- XCTAssertEqual(INT_MAX, resumeAtBytes);
- XCTAssertEqualWithAccuracy(sqrt(INT_MAX - 499), computationResult, 0.1);
+ NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
+ NSURL *fileURL =
+ [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"txt"];
+
+ __block long resumeAtBytes = 256 * 1024;
+ __block long downloadedBytes = 0;
+ __block double computationResult = 0;
+
+ FIRStorageDownloadTask *task = [ref writeToFile:fileURL];
+
+ [task observeStatus:FIRStorageTaskStatusSuccess
+ handler:^(FIRStorageTaskSnapshot *snapshot) {
+ XCTAssertEqualObjects([snapshot description], @"<State: Success>");
+ [expectation fulfill];
+ }];
+
+ [task observeStatus:FIRStorageTaskStatusProgress
+ handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
+ XCTAssertTrue([[snapshot description] containsString:@"State: Progress"] ||
+ [[snapshot description] containsString:@"State: Resume"]);
+ NSProgress *progress = snapshot.progress;
+ XCTAssertGreaterThanOrEqual(progress.completedUnitCount, downloadedBytes);
+ downloadedBytes = progress.completedUnitCount;
+ if (progress.completedUnitCount > resumeAtBytes) {
+ // Making sure the main run loop is busy.
+ for (int i = 0; i < 500; ++i) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ computationResult = sqrt(INT_MAX - i);
+ });
+ }
+ NSLog(@"Pausing");
+ [task pause];
+ resumeAtBytes = INT_MAX;
+ }
+ }];
+
+ [task observeStatus:FIRStorageTaskStatusPause
+ handler:^(FIRStorageTaskSnapshot *snapshot) {
+ XCTAssertEqualObjects([snapshot description], @"<State: Paused>");
+ NSLog(@"Resuming");
+ [task resume];
+ }];
+
+ [self waitForExpectations];
+ XCTAssertEqual(INT_MAX, resumeAtBytes);
+ XCTAssertEqualWithAccuracy(sqrt(INT_MAX - 499), computationResult, 0.1);
}
- (void)waitForExpectations {
- [self waitForExpectationsWithTimeout:kFIRStorageIntegrationTestTimeout
- handler:^(NSError *_Nullable error) {
- if (error) {
- NSLog(@"%@", error);
- }
- }];
+ [self waitForExpectationsWithTimeout:kFIRStorageIntegrationTestTimeout
+ handler:^(NSError *_Nullable error) {
+ if (error) {
+ NSLog(@"%@", error);
+ }
+ }];
}
@end
diff --git a/Example/Storage/Tests/Unit/FIRStorageDeleteTests.m b/Example/Storage/Tests/Unit/FIRStorageDeleteTests.m
index 42a3b1a..4311ab3 100644
--- a/Example/Storage/Tests/Unit/FIRStorageDeleteTests.m
+++ b/Example/Storage/Tests/Unit/FIRStorageDeleteTests.m
@@ -29,7 +29,7 @@
- (void)setUp {
[super setUp];
- NSDictionary *metadataDict = @{ @"bucket" : @"bucket", @"name" : @"path/to/object" };
+ NSDictionary *metadataDict = @{@"bucket" : @"bucket", @"name" : @"path/to/object"};
self.metadata = [[FIRStorageMetadata alloc] initWithDictionary:metadataDict];
id mockOptions = OCMClassMock([FIROptions class]);
@@ -64,11 +64,10 @@
XCTAssertEqualObjects(fetcher.request.URL, [FIRStorageTestHelpers objectURL]);
#pragma clang diagnostic pop
XCTAssertEqualObjects(fetcher.request.HTTPMethod, @"DELETE");
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, nil);
};
@@ -108,14 +107,13 @@
self.fetcherService.testBlock = [FIRStorageTestHelpers unauthenticatedBlock];
FIRStoragePath *path = [FIRStorageTestHelpers objectPath];
FIRStorageReference *ref = [[FIRStorageReference alloc] initWithStorage:self.storage path:path];
- FIRStorageDeleteTask *task =
- [[FIRStorageDeleteTask alloc] initWithReference:ref
- fetcherService:self.fetcherService
- completion:^(NSError *error) {
- XCTAssertEqual(error.code,
- FIRStorageErrorCodeUnauthenticated);
- [expectation fulfill];
- }];
+ FIRStorageDeleteTask *task = [[FIRStorageDeleteTask alloc]
+ initWithReference:ref
+ fetcherService:self.fetcherService
+ completion:^(NSError *error) {
+ XCTAssertEqual(error.code, FIRStorageErrorCodeUnauthenticated);
+ [expectation fulfill];
+ }];
[task enqueue];
[FIRStorageTestHelpers waitForExpectation:self];
@@ -128,14 +126,13 @@
self.fetcherService.testBlock = [FIRStorageTestHelpers unauthorizedBlock];
FIRStoragePath *path = [FIRStorageTestHelpers objectPath];
FIRStorageReference *ref = [[FIRStorageReference alloc] initWithStorage:self.storage path:path];
- FIRStorageDeleteTask *task =
- [[FIRStorageDeleteTask alloc] initWithReference:ref
- fetcherService:self.fetcherService
- completion:^(NSError *error) {
- XCTAssertEqual(error.code,
- FIRStorageErrorCodeUnauthorized);
- [expectation fulfill];
- }];
+ FIRStorageDeleteTask *task = [[FIRStorageDeleteTask alloc]
+ initWithReference:ref
+ fetcherService:self.fetcherService
+ completion:^(NSError *error) {
+ XCTAssertEqual(error.code, FIRStorageErrorCodeUnauthorized);
+ [expectation fulfill];
+ }];
[task enqueue];
[FIRStorageTestHelpers waitForExpectation:self];
@@ -148,14 +145,13 @@
self.fetcherService.testBlock = [FIRStorageTestHelpers notFoundBlock];
FIRStoragePath *path = [FIRStorageTestHelpers notFoundPath];
FIRStorageReference *ref = [[FIRStorageReference alloc] initWithStorage:self.storage path:path];
- FIRStorageDeleteTask *task =
- [[FIRStorageDeleteTask alloc] initWithReference:ref
- fetcherService:self.fetcherService
- completion:^(NSError *error) {
- XCTAssertEqual(error.code,
- FIRStorageErrorCodeObjectNotFound);
- [expectation fulfill];
- }];
+ FIRStorageDeleteTask *task = [[FIRStorageDeleteTask alloc]
+ initWithReference:ref
+ fetcherService:self.fetcherService
+ completion:^(NSError *error) {
+ XCTAssertEqual(error.code, FIRStorageErrorCodeObjectNotFound);
+ [expectation fulfill];
+ }];
[task enqueue];
[FIRStorageTestHelpers waitForExpectation:self];
diff --git a/Example/Storage/Tests/Unit/FIRStorageGetMetadataTests.m b/Example/Storage/Tests/Unit/FIRStorageGetMetadataTests.m
index 72a057d..1f19b00 100644
--- a/Example/Storage/Tests/Unit/FIRStorageGetMetadataTests.m
+++ b/Example/Storage/Tests/Unit/FIRStorageGetMetadataTests.m
@@ -29,7 +29,7 @@
- (void)setUp {
[super setUp];
- NSDictionary *metadataDict = @{ @"bucket" : @"bucket", @"name" : @"path/to/object" };
+ NSDictionary *metadataDict = @{@"bucket" : @"bucket", @"name" : @"path/to/object"};
self.metadata = [[FIRStorageMetadata alloc] initWithDictionary:metadataDict];
id mockOptions = OCMClassMock([FIROptions class]);
@@ -64,11 +64,10 @@
XCTAssertEqualObjects(fetcher.request.URL, [FIRStorageTestHelpers objectURL]);
#pragma clang diagnostic pop
XCTAssertEqualObjects(fetcher.request.HTTPMethod, @"GET");
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, nil);
};
diff --git a/Example/Storage/Tests/Unit/FIRStorageMetadataTests.m b/Example/Storage/Tests/Unit/FIRStorageMetadataTests.m
index e750bdf..d6a73e7 100644
--- a/Example/Storage/Tests/Unit/FIRStorageMetadataTests.m
+++ b/Example/Storage/Tests/Unit/FIRStorageMetadataTests.m
@@ -263,16 +263,16 @@
}
- (void)testUpdatedMetadataWithEmptyUpdate {
- NSDictionary *oldMetadata = @{
- kFIRStorageMetadataContentLanguage : @"old",
- kFIRStorageMetadataCustomMetadata : @{@"foo" : @"old", @"bar" : @"old"}
- };
- FIRStorageMetadata *metadata = [[FIRStorageMetadata alloc] initWithDictionary:oldMetadata];
+ NSDictionary *oldMetadata = @{
+ kFIRStorageMetadataContentLanguage : @"old",
+ kFIRStorageMetadataCustomMetadata : @{@"foo" : @"old", @"bar" : @"old"}
+ };
+ FIRStorageMetadata *metadata = [[FIRStorageMetadata alloc] initWithDictionary:oldMetadata];
- NSDictionary *update = [metadata updatedMetadata];
+ NSDictionary *update = [metadata updatedMetadata];
- NSDictionary *expectedUpdate = @{ kFIRStorageMetadataCustomMetadata : @{} };
- XCTAssertEqualObjects(update, expectedUpdate);
+ NSDictionary *expectedUpdate = @{ kFIRStorageMetadataCustomMetadata : @{} };
+ XCTAssertEqualObjects(update, expectedUpdate);
}
- (void)testUpdatedMetadataWithDelete {
@@ -305,31 +305,31 @@
}
- (void)testZuluTimeOffset {
- NSDictionary *metaDict = @{ kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108Z" };
+ NSDictionary *metaDict = @{kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108Z"};
FIRStorageMetadata *metadata = [[FIRStorageMetadata alloc] initWithDictionary:metaDict];
XCTAssertNotNil(metadata.timeCreated);
}
- (void)testZuluZeroTimeOffset {
- NSDictionary *metaDict = @{ kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108+0000" };
+ NSDictionary *metaDict = @{kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108+0000"};
FIRStorageMetadata *metadata = [[FIRStorageMetadata alloc] initWithDictionary:metaDict];
XCTAssertNotNil(metadata.timeCreated);
}
- (void)testGoogleStandardTimeOffset {
- NSDictionary *metaDict = @{ kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108-0700" };
+ NSDictionary *metaDict = @{kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108-0700"};
FIRStorageMetadata *metadata = [[FIRStorageMetadata alloc] initWithDictionary:metaDict];
XCTAssertNotNil(metadata.timeCreated);
}
- (void)testUnspecifiedTimeOffset {
- NSDictionary *metaDict = @{ kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108-0000" };
+ NSDictionary *metaDict = @{kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108-0000"};
FIRStorageMetadata *metadata = [[FIRStorageMetadata alloc] initWithDictionary:metaDict];
XCTAssertNotNil(metadata.timeCreated);
}
- (void)testNoTimeOffset {
- NSDictionary *metaDict = @{ kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108" };
+ NSDictionary *metaDict = @{kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108"};
FIRStorageMetadata *metadata = [[FIRStorageMetadata alloc] initWithDictionary:metaDict];
XCTAssertNil(metadata.timeCreated);
}
diff --git a/Example/Storage/Tests/Unit/FIRStorageTestHelpers.m b/Example/Storage/Tests/Unit/FIRStorageTestHelpers.m
index fef67ef..2039f22 100644
--- a/Example/Storage/Tests/Unit/FIRStorageTestHelpers.m
+++ b/Example/Storage/Tests/Unit/FIRStorageTestHelpers.m
@@ -97,16 +97,15 @@ NSString *const kFIRStorageAppName = @"app";
+ (GTMSessionFetcherTestBlock)blockForData:(nullable NSData *)data statusCode:(NSInteger)code {
GTMSessionFetcherTestBlock block =
^(GTMSessionFetcher *fetcher, GTMSessionFetcherTestResponse response) {
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:code
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:code
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
NSError *error;
if (code >= 400) {
NSDictionary *userInfo;
if (data) {
- userInfo = @{ @"data" : data };
+ userInfo = @{@"data" : data};
}
error = [NSError errorWithDomain:kGoogleHTTPErrorDomain code:code userInfo:userInfo];
}
diff --git a/Example/Storage/Tests/Unit/FIRStorageTests.m b/Example/Storage/Tests/Unit/FIRStorageTests.m
index 1b45295..503ac94 100644
--- a/Example/Storage/Tests/Unit/FIRStorageTests.m
+++ b/Example/Storage/Tests/Unit/FIRStorageTests.m
@@ -43,7 +43,7 @@
}
- (void)testBucketNotEnforced {
- FIROptions * mockOptions = OCMClassMock([FIROptions class]);
+ FIROptions *mockOptions = OCMClassMock([FIROptions class]);
OCMStub([mockOptions storageBucket]).andReturn(@"");
FIRApp *app = OCMClassMock([FIRApp class]);
OCMStub([app name]).andReturn(kFIRStorageAppName);
@@ -55,40 +55,39 @@
}
- (void)testBucketEnforced {
- FIRStorage *storage = [FIRStorage storageForApp:self.app
- URL:@"gs://benwu-test1.storage.firebase.com"];
+ FIRStorage *storage =
+ [FIRStorage storageForApp:self.app URL:@"gs://benwu-test1.storage.firebase.com"];
[storage referenceForURL:@"gs://benwu-test1.storage.firebase.com/child"];
storage = [FIRStorage storageForApp:self.app URL:@"gs://benwu-test1.storage.firebase.com/"];
[storage referenceForURL:@"gs://benwu-test1.storage.firebase.com/child"];
XCTAssertThrows([storage referenceForURL:@"gs://benwu-test2.storage.firebase.com/child"]);
}
-- (void) testInitWithCustomUrl {
+- (void)testInitWithCustomUrl {
FIRStorage *storage = [FIRStorage storageForApp:self.app URL:@"gs://foo-bar.appspot.com"];
XCTAssertEqualObjects(@"gs://foo-bar.appspot.com/", [[storage reference] description]);
storage = [FIRStorage storageForApp:self.app URL:@"gs://foo-bar.appspot.com/"];
XCTAssertEqualObjects(@"gs://foo-bar.appspot.com/", [[storage reference] description]);
}
-- (void) testInitWithWrongScheme {
+- (void)testInitWithWrongScheme {
XCTAssertThrows([FIRStorage storageForApp:self.app URL:@"http://foo-bar.appspot.com"]);
}
-- (void) testInitWithNoScheme {
+- (void)testInitWithNoScheme {
XCTAssertThrows([FIRStorage storageForApp:self.app URL:@"foo-bar.appspot.com"]);
}
-- (void) testInitWithNilURL {
+- (void)testInitWithNilURL {
XCTAssertThrows([FIRStorage storageForApp:self.app URL:nil]);
}
-- (void) testInitWithPath {
+- (void)testInitWithPath {
XCTAssertThrows([FIRStorage storageForApp:self.app URL:@"gs://foo-bar.appspot.com/child"]);
}
-- (void) testInitWithDefaultAndCustomUrl {
- FIRStorage *customInstance = [FIRStorage storageForApp:self.app
- URL:@"gs://foo-bar.appspot.com"];
+- (void)testInitWithDefaultAndCustomUrl {
+ FIRStorage *customInstance = [FIRStorage storageForApp:self.app URL:@"gs://foo-bar.appspot.com"];
FIRStorage *defaultInstance = [FIRStorage storageForApp:self.app];
XCTAssertEqualObjects(@"gs://foo-bar.appspot.com/", [[customInstance reference] description]);
XCTAssertEqualObjects(@"gs://bucket/", [[defaultInstance reference] description]);
diff --git a/Example/Storage/Tests/Unit/FIRStorageTokenAuthorizerTests.m b/Example/Storage/Tests/Unit/FIRStorageTokenAuthorizerTests.m
index bc60fb4..26627b5 100644
--- a/Example/Storage/Tests/Unit/FIRStorageTokenAuthorizerTests.m
+++ b/Example/Storage/Tests/Unit/FIRStorageTokenAuthorizerTests.m
@@ -56,23 +56,22 @@
#pragma clang diagnostic ignored "-Warc-retain-cycles"
XCTAssertTrue([self.fetcher.authorizer isAuthorizedRequest:fetcher.request]);
#pragma clang diagnostic pop
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, nil);
};
- [self.fetcher beginFetchWithCompletionHandler:^(NSData *_Nullable data,
- NSError *_Nullable error) {
- NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
- NSString *authHeader = [headers objectForKey:@"Authorization"];
- NSString *firebaseToken =
- [NSString stringWithFormat:kFIRStorageAuthTokenFormat, kFIRStorageTestAuthToken];
- XCTAssertEqualObjects(authHeader, firebaseToken);
- [expectation fulfill];
- }];
+ [self.fetcher
+ beginFetchWithCompletionHandler:^(NSData *_Nullable data, NSError *_Nullable error) {
+ NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
+ NSString *authHeader = [headers objectForKey:@"Authorization"];
+ NSString *firebaseToken =
+ [NSString stringWithFormat:kFIRStorageAuthTokenFormat, kFIRStorageTestAuthToken];
+ XCTAssertEqualObjects(authHeader, firebaseToken);
+ [expectation fulfill];
+ }];
[FIRStorageTestHelpers waitForExpectation:self];
}
@@ -98,23 +97,22 @@
#pragma clang diagnostic ignored "-Warc-retain-cycles"
XCTAssertEqual([self.fetcher.authorizer isAuthorizedRequest:fetcher.request], NO);
#pragma cland diagnostic pop
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:401
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:401
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, authError);
};
- [self.fetcher beginFetchWithCompletionHandler:^(NSData *_Nullable data,
- NSError *_Nullable error) {
- NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
- NSString *authHeader = [headers objectForKey:@"Authorization"];
- XCTAssertNil(authHeader);
- XCTAssertEqualObjects(error.domain, FIRStorageErrorDomain);
- XCTAssertEqual(error.code, FIRStorageErrorCodeUnauthenticated);
- [expectation fulfill];
- }];
+ [self.fetcher
+ beginFetchWithCompletionHandler:^(NSData *_Nullable data, NSError *_Nullable error) {
+ NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
+ NSString *authHeader = [headers objectForKey:@"Authorization"];
+ XCTAssertNil(authHeader);
+ XCTAssertEqualObjects(error.domain, FIRStorageErrorDomain);
+ XCTAssertEqual(error.code, FIRStorageErrorCodeUnauthenticated);
+ [expectation fulfill];
+ }];
[FIRStorageTestHelpers waitForExpectation:self];
}
@@ -134,22 +132,21 @@
#pragma clang diagnostic ignored "-Warc-retain-cycles"
XCTAssertFalse([self.fetcher.authorizer isAuthorizedRequest:fetcher.request]);
#pragma cland diagnostic pop
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, nil);
};
- [self.fetcher beginFetchWithCompletionHandler:^(NSData *_Nullable data,
- NSError *_Nullable error) {
- NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
- NSString *authHeader = [headers objectForKey:@"Authorization"];
- XCTAssertNil(authHeader);
- XCTAssertNil(error);
- [expectation fulfill];
- }];
+ [self.fetcher
+ beginFetchWithCompletionHandler:^(NSData *_Nullable data, NSError *_Nullable error) {
+ NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
+ NSString *authHeader = [headers objectForKey:@"Authorization"];
+ XCTAssertNil(authHeader);
+ XCTAssertNil(error);
+ [expectation fulfill];
+ }];
[FIRStorageTestHelpers waitForExpectation:self];
}
@@ -159,11 +156,10 @@
self.fetcher.testBlock = ^(GTMSessionFetcher *fetcher, GTMSessionFetcherTestResponse response) {
XCTAssertFalse([fetcher.authorizer isAuthorizingRequest:fetcher.request]);
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, nil);
};
@@ -183,23 +179,22 @@
// will still result in successful authentication
[fetcher.authorizer stopAuthorization];
[fetcher.authorizer stopAuthorizationForRequest:fetcher.request];
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, nil);
};
- [self.fetcher beginFetchWithCompletionHandler:^(NSData *_Nullable data,
- NSError *_Nullable error) {
- NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
- NSString *authHeader = [headers objectForKey:@"Authorization"];
- NSString *firebaseToken =
- [NSString stringWithFormat:kFIRStorageAuthTokenFormat, kFIRStorageTestAuthToken];
- XCTAssertEqualObjects(authHeader, firebaseToken);
- [expectation fulfill];
- }];
+ [self.fetcher
+ beginFetchWithCompletionHandler:^(NSData *_Nullable data, NSError *_Nullable error) {
+ NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
+ NSString *authHeader = [headers objectForKey:@"Authorization"];
+ NSString *firebaseToken =
+ [NSString stringWithFormat:kFIRStorageAuthTokenFormat, kFIRStorageTestAuthToken];
+ XCTAssertEqualObjects(authHeader, firebaseToken);
+ [expectation fulfill];
+ }];
[FIRStorageTestHelpers waitForExpectation:self];
}
@@ -209,11 +204,10 @@
self.fetcher.testBlock = ^(GTMSessionFetcher *fetcher, GTMSessionFetcherTestResponse response) {
XCTAssertNil([fetcher.authorizer userEmail]);
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, nil);
};
diff --git a/Example/Storage/Tests/Unit/FIRStorageUpdateMetadataTests.m b/Example/Storage/Tests/Unit/FIRStorageUpdateMetadataTests.m
index d2d2950..62ac6a5 100644
--- a/Example/Storage/Tests/Unit/FIRStorageUpdateMetadataTests.m
+++ b/Example/Storage/Tests/Unit/FIRStorageUpdateMetadataTests.m
@@ -30,7 +30,7 @@
- (void)setUp {
[super setUp];
- NSDictionary *metadataDict = @{ @"bucket" : @"bucket", @"name" : @"path/to/object" };
+ NSDictionary *metadataDict = @{@"bucket" : @"bucket", @"name" : @"path/to/object"};
self.metadata = [[FIRStorageMetadata alloc] initWithDictionary:metadataDict];
id mockOptions = OCMClassMock([FIROptions class]);
@@ -58,26 +58,25 @@
- (void)testFetcherConfiguration {
XCTestExpectation *expectation = [self expectationWithDescription:@"testSuccessfulFetch"];
- self.fetcherService.testBlock = ^(GTMSessionFetcher *fetcher,
- GTMSessionFetcherTestResponse response) {
+ self.fetcherService.testBlock =
+ ^(GTMSessionFetcher *fetcher, GTMSessionFetcherTestResponse response) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
- XCTAssertEqualObjects(fetcher.request.URL, [FIRStorageTestHelpers objectURL]);
- XCTAssertEqualObjects(fetcher.request.HTTPMethod, @"PATCH");
- NSData *bodyData = [NSData frs_dataFromJSONDictionary:[self.metadata updatedMetadata]];
- XCTAssertEqualObjects(fetcher.request.HTTPBody, bodyData);
- NSDictionary *HTTPHeaders = fetcher.request.allHTTPHeaderFields;
- XCTAssertEqualObjects(HTTPHeaders[@"Content-Type"], @"application/json; charset=UTF-8");
- XCTAssertEqualObjects(HTTPHeaders[@"Content-Length"], [@(bodyData.length) stringValue]);
+ XCTAssertEqualObjects(fetcher.request.URL, [FIRStorageTestHelpers objectURL]);
+ XCTAssertEqualObjects(fetcher.request.HTTPMethod, @"PATCH");
+ NSData *bodyData = [NSData frs_dataFromJSONDictionary:[self.metadata updatedMetadata]];
+ XCTAssertEqualObjects(fetcher.request.HTTPBody, bodyData);
+ NSDictionary *HTTPHeaders = fetcher.request.allHTTPHeaderFields;
+ XCTAssertEqualObjects(HTTPHeaders[@"Content-Type"], @"application/json; charset=UTF-8");
+ XCTAssertEqualObjects(HTTPHeaders[@"Content-Length"], [@(bodyData.length) stringValue]);
#pragma clang diagnostic pop
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
- response(httpResponse, nil, nil);
- self.fetcherService.testBlock = nil;
- };
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
+ response(httpResponse, nil, nil);
+ self.fetcherService.testBlock = nil;
+ };
FIRStoragePath *path = [FIRStorageTestHelpers objectPath];
FIRStorageReference *ref = [[FIRStorageReference alloc] initWithStorage:self.storage path:path];
diff --git a/Example/Storage/Tests/Unit/FIRStorageUtilsTests.m b/Example/Storage/Tests/Unit/FIRStorageUtilsTests.m
index 8bf4c7e..7e4a046 100644
--- a/Example/Storage/Tests/Unit/FIRStorageUtilsTests.m
+++ b/Example/Storage/Tests/Unit/FIRStorageUtilsTests.m
@@ -43,7 +43,7 @@
NSString *JSONString = @"{\"hello\" : \"world\"}";
NSData *JSONData = [JSONString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *JSONDictionary = [NSDictionary frs_dictionaryFromJSONData:JSONData];
- NSDictionary *expectedDictionary = @{ @"hello" : @"world" };
+ NSDictionary *expectedDictionary = @{@"hello" : @"world"};
XCTAssertEqualObjects(JSONDictionary, expectedDictionary);
}
@@ -60,7 +60,7 @@
}
- (void)testParseGoodDictToData {
- NSDictionary *JSONDictionary = @{ @"hello" : @"world" };
+ NSDictionary *JSONDictionary = @{@"hello" : @"world"};
NSData *expectedData = [NSData frs_dataFromJSONDictionary:JSONDictionary];
NSString *JSONString = [[NSString alloc] initWithData:expectedData encoding:NSUTF8StringEncoding];
NSString *expectedString = @"{\"hello\":\"world\"}";
@@ -85,13 +85,13 @@
}
- (void)testSingleItemToQueryString {
- NSDictionary *params = @{ @"foo" : @"bar" };
+ NSDictionary *params = @{@"foo" : @"bar"};
NSString *queryString = [FIRStorageUtils queryStringForDictionary:params];
XCTAssertEqualObjects(queryString, @"foo=bar");
}
- (void)testMultiItemDictToQueryString {
- NSDictionary *params = @{ @"foo" : @"bar", @"baz" : @"qux" };
+ NSDictionary *params = @{@"foo" : @"bar", @"baz" : @"qux"};
NSString *queryString = [FIRStorageUtils queryStringForDictionary:params];
XCTAssertEqualObjects(queryString, @"foo=bar&baz=qux");
}