diff options
Diffstat (limited to 'Firestore/Example/Tests/Util/FSTHelpers.mm')
-rw-r--r-- | Firestore/Example/Tests/Util/FSTHelpers.mm | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/Firestore/Example/Tests/Util/FSTHelpers.mm b/Firestore/Example/Tests/Util/FSTHelpers.mm index 64fe213..406d4dd 100644 --- a/Firestore/Example/Tests/Util/FSTHelpers.mm +++ b/Firestore/Example/Tests/Util/FSTHelpers.mm @@ -17,6 +17,7 @@ #import "Firestore/Example/Tests/Util/FSTHelpers.h" #include <inttypes.h> +#include <vector> #import <FirebaseFirestore/FIRFieldPath.h> #import <FirebaseFirestore/FIRGeoPoint.h> @@ -30,7 +31,6 @@ #import "Firestore/Source/Core/FSTViewSnapshot.h" #import "Firestore/Source/Local/FSTLocalViewChanges.h" #import "Firestore/Source/Local/FSTQueryData.h" -#import "Firestore/Source/Model/FSTDatabaseID.h" #import "Firestore/Source/Model/FSTDocument.h" #import "Firestore/Source/Model/FSTDocumentKey.h" #import "Firestore/Source/Model/FSTDocumentSet.h" @@ -41,6 +41,12 @@ #import "Firestore/Source/Remote/FSTWatchChange.h" #import "Firestore/Source/Util/FSTAssert.h" +#include "Firestore/core/src/firebase/firestore/model/database_id.h" +#include "Firestore/core/src/firebase/firestore/util/string_apple.h" + +namespace util = firebase::firestore::util; +using firebase::firestore::model::DatabaseId; + NS_ASSUME_NONNULL_BEGIN /** A string sentinel that can be used with FSTTestPatchMutation() to mark a field for deletion. */ @@ -100,10 +106,10 @@ FSTFieldPath *FSTTestFieldPath(NSString *field) { } FSTFieldValue *FSTTestFieldValue(id _Nullable value) { - FSTDatabaseID *databaseID = - [FSTDatabaseID databaseIDWithProject:@"project" database:kDefaultDatabaseID]; + // This owns the DatabaseIds since we do not have FirestoreClient instance to own them. + static DatabaseId database_id{"project", DatabaseId::kDefaultDatabaseId}; FSTUserDataConverter *converter = - [[FSTUserDataConverter alloc] initWithDatabaseID:databaseID + [[FSTUserDataConverter alloc] initWithDatabaseID:&database_id preConverter:^id _Nullable(id _Nullable input) { return input; }]; @@ -167,8 +173,11 @@ FSTResourcePath *FSTTestPath(NSString *path) { } FSTDocumentKeyReference *FSTTestRef(NSString *projectID, NSString *database, NSString *path) { - FSTDatabaseID *databaseID = [FSTDatabaseID databaseIDWithProject:projectID database:database]; - return [[FSTDocumentKeyReference alloc] initWithKey:FSTTestDocKey(path) databaseID:databaseID]; + // This owns the DatabaseIds since we do not have FirestoreClient instance to own them. + static std::vector<DatabaseId> database_ids; + database_ids.emplace_back(util::MakeStringView(projectID), util::MakeStringView(database)); + return [[FSTDocumentKeyReference alloc] initWithKey:FSTTestDocKey(path) + databaseID:&database_ids.back()]; } FSTQuery *FSTTestQuery(NSString *path) { |