@@ -36,10 +36,14 @@ public static void setUp() {
36
36
app = FirebaseApp .getInstance ();
37
37
}
38
38
39
+ private void useTestURL (FirebaseFunctions functions ) {
40
+ functions .useFunctionsEmulator ("http://10.0.2.2:5005" );
41
+ }
42
+
39
43
@ Test
40
44
public void testData () throws InterruptedException , ExecutionException {
41
45
FirebaseFunctions functions = FirebaseFunctions .getInstance (app );
42
- functions . setUseTestURL ( true );
46
+ useTestURL ( functions );
43
47
44
48
Map <String , Object > params = new HashMap <>();
45
49
params .put ("bool" , true );
@@ -63,7 +67,7 @@ public void testData() throws InterruptedException, ExecutionException {
63
67
@ Test
64
68
public void testScalars () throws InterruptedException , ExecutionException {
65
69
FirebaseFunctions functions = FirebaseFunctions .getInstance (app );
66
- functions . setUseTestURL ( true );
70
+ useTestURL ( functions );
67
71
68
72
HttpsCallableReference function = functions .getHttpsCallable ("scalarTest" );
69
73
Task <HttpsCallableResult > result = function .call (17 );
@@ -87,7 +91,7 @@ public Task<HttpsCallableContext> getContext() {
87
91
return Tasks .forResult (context );
88
92
}
89
93
});
90
- functions . setUseTestURL ( true );
94
+ useTestURL ( functions );
91
95
92
96
HttpsCallableReference function = functions .getHttpsCallable ("tokenTest" );
93
97
Task <HttpsCallableResult > result = function .call (new HashMap <>());
@@ -111,7 +115,7 @@ public Task<HttpsCallableContext> getContext() {
111
115
return Tasks .forResult (context );
112
116
}
113
117
});
114
- functions . setUseTestURL ( true );
118
+ useTestURL ( functions );
115
119
116
120
HttpsCallableReference function = functions .getHttpsCallable ("instanceIdTest" );
117
121
Task <HttpsCallableResult > result = function .call (new HashMap <>());
@@ -123,7 +127,7 @@ public Task<HttpsCallableContext> getContext() {
123
127
@ Test
124
128
public void testNull () throws InterruptedException , ExecutionException {
125
129
FirebaseFunctions functions = FirebaseFunctions .getInstance (app );
126
- functions . setUseTestURL ( true );
130
+ useTestURL ( functions );
127
131
128
132
HttpsCallableReference function = functions .getHttpsCallable ("nullTest" );
129
133
Task <HttpsCallableResult > result = function .call (null );
@@ -139,7 +143,7 @@ public void testNull() throws InterruptedException, ExecutionException {
139
143
@ Test
140
144
public void testMissingResult () throws InterruptedException , ExecutionException {
141
145
FirebaseFunctions functions = FirebaseFunctions .getInstance (app );
142
- functions . setUseTestURL ( true );
146
+ useTestURL ( functions );
143
147
144
148
HttpsCallableReference function = functions .getHttpsCallable ("missingResultTest" );
145
149
Task <HttpsCallableResult > result = function .call (null );
@@ -155,7 +159,7 @@ public void testMissingResult() throws InterruptedException, ExecutionException
155
159
@ Test
156
160
public void testUnhandledError () throws InterruptedException , ExecutionException {
157
161
FirebaseFunctions functions = FirebaseFunctions .getInstance (app );
158
- functions . setUseTestURL ( true );
162
+ useTestURL ( functions );
159
163
160
164
HttpsCallableReference function = functions .getHttpsCallable ("unhandledErrorTest" );
161
165
Task <HttpsCallableResult > result = function .call ();
@@ -171,7 +175,7 @@ public void testUnhandledError() throws InterruptedException, ExecutionException
171
175
@ Test
172
176
public void testUnknownError () throws InterruptedException , ExecutionException {
173
177
FirebaseFunctions functions = FirebaseFunctions .getInstance (app );
174
- functions . setUseTestURL ( true );
178
+ useTestURL ( functions );
175
179
176
180
HttpsCallableReference function = functions .getHttpsCallable ("unknownErrorTest" );
177
181
Task <HttpsCallableResult > result = function .call ();
@@ -187,7 +191,7 @@ public void testUnknownError() throws InterruptedException, ExecutionException {
187
191
@ Test
188
192
public void testExplicitError () throws InterruptedException , ExecutionException {
189
193
FirebaseFunctions functions = FirebaseFunctions .getInstance (app );
190
- functions . setUseTestURL ( true );
194
+ useTestURL ( functions );
191
195
192
196
HttpsCallableReference function = functions .getHttpsCallable ("explicitErrorTest" );
193
197
Task <HttpsCallableResult > result = function .call ();
@@ -208,7 +212,7 @@ public void testExplicitError() throws InterruptedException, ExecutionException
208
212
@ Test
209
213
public void testHttpError () throws InterruptedException , ExecutionException {
210
214
FirebaseFunctions functions = FirebaseFunctions .getInstance (app );
211
- functions . setUseTestURL ( true );
215
+ useTestURL ( functions );
212
216
213
217
HttpsCallableReference function = functions .getHttpsCallable ("httpErrorTest" );
214
218
Task <HttpsCallableResult > result = function .call ();
0 commit comments