Skip to content

Commit 0d9b27e

Browse files
authored
Fixing some failing RTDB tests (#334)
* Fixing some failing RTDB tests * Using explicit options * Refactored options initialization
1 parent 5f1e48c commit 0d9b27e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/test/java/com/google/firebase/database/FirebaseDatabaseTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@
3838

3939
public class FirebaseDatabaseTest {
4040

41-
private static FirebaseOptions firebaseOptions =
41+
private static final FirebaseOptions firebaseOptions =
4242
new FirebaseOptions.Builder()
4343
.setCredentials(TestUtils.getCertCredential(ServiceAccount.EDITOR.asStream()))
4444
.setDatabaseUrl("https://firebase-db-test.firebaseio.com")
4545
.build();
46+
private static final FirebaseOptions firebaseOptionsWithoutDatabaseUrl =
47+
new FirebaseOptions.Builder()
48+
.setCredentials(TestUtils.getCertCredential(ServiceAccount.EDITOR.asStream()))
49+
.build();
4650

4751
@Test
4852
public void testGetInstance() {
@@ -210,9 +214,10 @@ public void testDbUrlIsEmulatorUrlWhenSettingOptionsManually() {
210214
new CustomTestCase("https://test.firebaseio.com?ns=valid-namespace", "localhost:90",
211215
"http://localhost:90", "valid-namespace")
212216
);
217+
213218
for (CustomTestCase tc : testCases) {
214219
try {
215-
FirebaseApp app = FirebaseApp.initializeApp();
220+
FirebaseApp app = FirebaseApp.initializeApp(firebaseOptionsWithoutDatabaseUrl);
216221
TestUtils.setEnvironmentVariables(
217222
ImmutableMap.of(EmulatorHelper.FIREBASE_RTDB_EMULATOR_HOST_ENV_VAR,
218223
Strings.nullToEmpty(tc.envVariableUrl)));
@@ -249,7 +254,7 @@ public void testDbUrlIsEmulatorUrlForDbRefWithPath() {
249254

250255
for (CustomTestCase tc : testCases) {
251256
try {
252-
FirebaseApp app = FirebaseApp.initializeApp();
257+
FirebaseApp app = FirebaseApp.initializeApp(firebaseOptionsWithoutDatabaseUrl);
253258
TestUtils.setEnvironmentVariables(
254259
ImmutableMap.of(EmulatorHelper.FIREBASE_RTDB_EMULATOR_HOST_ENV_VAR,
255260
Strings.nullToEmpty(tc.envVariableUrl)));

0 commit comments

Comments
 (0)