diff options
author | Sebastian Schmidt <mrschmidt@google.com> | 2017-09-15 16:45:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-15 16:45:46 -0700 |
commit | c6bde890ce2b352f86aa699b28f829d4cd85424c (patch) | |
tree | 4bb647eacb640c75d8447d4d2edc83d304ec2adb /Example | |
parent | 06a7c4f330fd7cdc01d16a15a277df538a49b25d (diff) |
Adding Multi-Resource support to the Firebase iOS SDK (#278)
* Adding Multi-Resource support to the Firebase iOS SDK.
This CL also makes RepoInfo hashable and simplifies RepoManager based on this.
Diffstat (limited to 'Example')
-rw-r--r-- | Example/Database/Tests/Integration/FIRDatabaseTests.m | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Example/Database/Tests/Integration/FIRDatabaseTests.m b/Example/Database/Tests/Integration/FIRDatabaseTests.m index 0e1c57c..a38f77d 100644 --- a/Example/Database/Tests/Integration/FIRDatabaseTests.m +++ b/Example/Database/Tests/Integration/FIRDatabaseTests.m @@ -32,6 +32,7 @@ @end static const NSInteger kFErrorCodeWriteCanceled = 3; +static NSString *kFirebaseTestAltNamespace = @"https://foobar.firebaseio.com"; @implementation FIRDatabaseTests @@ -50,9 +51,52 @@ static const NSInteger kFErrorCodeWriteCanceled = 3; - (void) testDatabaseForAppWithInvalidURLs { XCTAssertThrows([self databaseForURL:nil]); XCTAssertThrows([self databaseForURL:@"not-a-url"]); + XCTAssertThrows([self databaseForURL:@"http://fblocal.com"]); XCTAssertThrows([self databaseForURL:@"http://x.example.com/paths/are/bad"]); } +- (void)testDatabaseForAppWithURL { + id app = [[FIRFakeApp alloc] initWithName:@"testDatabaseForAppWithURL" URL:kFirebaseTestAltNamespace]; + FIRDatabase *database = [FIRDatabase databaseForApp:app URL:@"http://foo.bar.com"]; + XCTAssertEqualObjects(@"https://foo.bar.com", [database reference].URL); +} + +- (void)testDatabaseForAppWithURLAndPort { + id app = [[FIRFakeApp alloc] initWithName:@"testDatabaseForAppWithURLAndPort" + URL:kFirebaseTestAltNamespace]; + FIRDatabase *database = [FIRDatabase databaseForApp:app URL:@"http://foo.bar.com:80"]; + XCTAssertEqualObjects(@"http://foo.bar.com:80", [database reference].URL); +} + +- (void)testDatabaseForAppWithHttpsURL { + id app = [[FIRFakeApp alloc] initWithName:@"testDatabaseForAppWithHttpsURL" + URL:kFirebaseTestAltNamespace]; + FIRDatabase *database = [FIRDatabase databaseForApp:app URL:@"https://foo.bar.com"]; + XCTAssertEqualObjects(@"https://foo.bar.com", [database reference].URL); +} + +- (void)testDifferentInstanceForAppWithURL { + id app = [[FIRFakeApp alloc] initWithName:@"testDifferentInstanceForAppWithURL" + URL:kFirebaseTestAltNamespace]; + FIRDatabase *database1 = [FIRDatabase databaseForApp:app URL:@"https://foo1.bar.com"]; + FIRDatabase *database2 = [FIRDatabase databaseForApp:app URL:@"https://foo1.bar.com/"]; + FIRDatabase *database3 = [FIRDatabase databaseForApp:app URL:@"https://foo2.bar.com"]; + XCTAssertEqual(database1, database2); + XCTAssertNotEqual(database1, database3); +} + +- (void)testDatabaseForAppWithInvalidCustomURLs { + id app = [[FIRFakeApp alloc] initWithName:@"testDatabaseForAppWithInvalidCustomURLs" + URL:kFirebaseTestAltNamespace]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonnull" + XCTAssertThrows([FIRDatabase databaseForApp:app URL:nil]); +#pragma clang diagnostic pop + XCTAssertThrows([FIRDatabase databaseForApp:app URL:@"not-a-url"]); + XCTAssertThrows([FIRDatabase databaseForApp:app URL:@"http://fblocal.com"]); + XCTAssertThrows([FIRDatabase databaseForApp:app URL:@"http://x.fblocal.com:9000/paths/are/bad"]); +} + - (void) testDeleteDatabase { // Set up a custom FIRApp with a custom database based on it. FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:@"1:123:ios:123abc" |