Skip to content

Commit 43c223c

Browse files
committed
chore: resolve comments and add test for Abort
1 parent 1404359 commit 43c223c

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable_options.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class TimeLimit extends AbortSignal {
5353
/// ```dart
5454
/// final signal = HttpsCallableOptions(webAbortSignal: Abort('User exited'));
5555
/// ```
56-
5756
class Abort extends AbortSignal {
5857
final Object? reason;
5958
Abort([this.reason]);
@@ -74,7 +73,6 @@ class Abort extends AbortSignal {
7473
/// ]),
7574
/// );
7675
/// ```
77-
7876
class Any extends AbortSignal {
7977
final List<AbortSignal> signals;
8078
Any(this.signals);

tests/integration_test/cloud_functions/cloud_functions_e2e_test.dart

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ void main() {
384384
});
385385

386386
test(
387-
'times out when aborted with TimeLimit signal',
387+
'throws error when aborted with TimeLimit signal',
388388
() async {
389389
final instance = FirebaseFunctions.instance;
390390
instance.useFunctionsEmulator('localhost', 5001);
@@ -404,7 +404,7 @@ void main() {
404404
},
405405
onError: (error) {
406406
if (error is FirebaseFunctionsException) {
407-
expect(error.code, equals('deadline-exceeded'));
407+
expect(error.code, equals('internal'));
408408
completer.complete();
409409
} else {
410410
completer.completeError('Unexpected error type: $error');
@@ -416,6 +416,29 @@ void main() {
416416
},
417417
skip: !kIsWeb,
418418
);
419+
420+
test(
421+
'throws error when aborted with Abort signal',
422+
() async {
423+
final completer = Completer<void>();
424+
425+
callable.stream().listen(
426+
(data) {
427+
completer.completeError('Should have thrown');
428+
},
429+
onError: (error) {
430+
if (error is FirebaseFunctionsException) {
431+
expect(error.code, equals('internal'));
432+
completer.complete();
433+
} else {
434+
completer.completeError('Unexpected error type: $error');
435+
}
436+
},
437+
);
438+
await completer.future;
439+
},
440+
skip: !kIsWeb,
441+
);
419442
});
420443
});
421444
}

0 commit comments

Comments
 (0)