aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/Tests/Util
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2017-11-27 21:00:18 -0800
committerGravatar GitHub <noreply@github.com>2017-11-27 21:00:18 -0800
commit7459be46ffb27bc95e155a1b267f91093f1a62b0 (patch)
tree597c8c304c9ef424988a02bd872542d0dcf6977f /Firestore/Example/Tests/Util
parent771b0f7a6574578bd1c7d1d3c333f26173f33e92 (diff)
Port autoid to C++ and remove FSTUtil (#475)
* Port autoid to C++ * Reimplement FSTUtil on top of firestore::CreateAutoId directly * Migrate FSTUtil callers to directly use firestore::CreateAutoId * Remove FSTUtil
Diffstat (limited to 'Firestore/Example/Tests/Util')
-rw-r--r--Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm9
-rw-r--r--Firestore/Example/Tests/Util/FSTUtilTests.m35
2 files changed, 6 insertions, 38 deletions
diff --git a/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm b/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
index 47d6e76..2c29bf0 100644
--- a/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
+++ b/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
@@ -21,12 +21,13 @@
#import <GRPCClient/GRPCCall+ChannelArg.h>
#import <GRPCClient/GRPCCall+Tests.h>
+#include "Firestore/src/core/util/autoid.h"
+
#import "Firestore/Source/API/FIRFirestore+Internal.h"
#import "Firestore/Source/Auth/FSTEmptyCredentialsProvider.h"
#import "Firestore/Source/Local/FSTLevelDB.h"
#import "Firestore/Source/Model/FSTDatabaseID.h"
#import "Firestore/Source/Util/FSTDispatchQueue.h"
-#import "Firestore/Source/Util/FSTUtil.h"
#import "Firestore/Example/Tests/Util/FSTEventAccumulator.h"
#import "Firestore/Example/Tests/Util/FSTTestDispatchQueue.h"
@@ -164,7 +165,8 @@ NS_ASSUME_NONNULL_BEGIN
}
- (NSString *)documentPath {
- return [@"test-collection/" stringByAppendingString:[FSTUtil autoID]];
+ std::string autoId = firestore::CreateAutoId();
+ return [NSString stringWithFormat:@"test-collection/%s", autoId.c_str()];
}
- (FIRDocumentReference *)documentRef {
@@ -172,7 +174,8 @@ NS_ASSUME_NONNULL_BEGIN
}
- (FIRCollectionReference *)collectionRef {
- NSString *collectionName = [@"test-collection-" stringByAppendingString:[FSTUtil autoID]];
+ std::string autoId = firestore::CreateAutoId();
+ NSString *collectionName = [NSString stringWithFormat:@"test-collection-%s", autoId.c_str()];
return [self.db collectionWithPath:collectionName];
}
diff --git a/Firestore/Example/Tests/Util/FSTUtilTests.m b/Firestore/Example/Tests/Util/FSTUtilTests.m
deleted file mode 100644
index d59ed7a..0000000
--- a/Firestore/Example/Tests/Util/FSTUtilTests.m
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2017 Google
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#import "Firestore/Source/Util/FSTUtil.h"
-
-#import <XCTest/XCTest.h>
-
-@interface FSTUtilTests : XCTestCase
-@end
-
-@implementation FSTUtilTests
-
-- (void)testAutoID {
- NSString *autoID = [FSTUtil autoID];
- XCTAssertEqual([autoID length], 20);
- for (NSUInteger i = 0; i < 20; i++) {
- unichar c = [autoID characterAtIndex:i];
- XCTAssert(c >= ' ' && c <= '~', @"Should be printable ascii characters.");
- }
-}
-
-@end