File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
main/java/com/google/firebase/cloud
test/java/com/google/firebase/cloud Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,8 @@ public static Firestore getFirestore() {
7979 */
8080 @ NonNull
8181 public static Firestore getFirestore (FirebaseApp app ) {
82- return getFirestore (app , ImplFirebaseTrampolines .getFirestoreOptions (app ).getDatabaseId ());
82+ final FirestoreOptions firestoreOptions = ImplFirebaseTrampolines .getFirestoreOptions (app );
83+ return getFirestore (app , firestoreOptions == null ? null : firestoreOptions .getDatabaseId ());
8384 }
8485
8586 /**
Original file line number Diff line number Diff line change @@ -79,6 +79,20 @@ public void testServiceAccountProjectId() throws IOException {
7979 assertNotSame (firestore1 , firestore2 );
8080 }
8181
82+ @ Test
83+ public void testAbsentFirestoreOptions () throws Exception {
84+ String projectId = "test-proj" ;
85+ FirebaseOptions options = FirebaseOptions .builder ()
86+ .setCredentials (GoogleCredentials .fromStream (ServiceAccount .EDITOR .asStream ()))
87+ .setProjectId (projectId )
88+ .build ();
89+
90+ FirebaseApp .initializeApp (options );
91+ Firestore firestore = FirestoreClient .getFirestore ();
92+ assertEquals (projectId , firestore .getOptions ().getProjectId ());
93+ assertEquals ("(default)" , firestore .getOptions ().getDatabaseId ());
94+ }
95+
8296 @ Test
8397 public void testFirestoreOptions () throws IOException {
8498 final String databaseId = "databaseIdInTestFirestoreOptions" ;
You can’t perform that action at this time.
0 commit comments