Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Unified Diff: test/with_guarantees_test.dart

Issue 1669953002: Provide more error-handling customization. (Closed) Base URL: git@github.com:dart-lang/stream_channel.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« lib/src/guarantee_channel.dart ('K') | « test/stream_channel_controller_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/with_guarantees_test.dart
diff --git a/test/with_guarantees_test.dart b/test/with_guarantees_test.dart
index 0e95f9d8832698951086eb658086f9cc5f1757e3..1de6e68da858d8282e5d54b09c4fecc27a6d6433 100644
--- a/test/with_guarantees_test.dart
+++ b/test/with_guarantees_test.dart
@@ -107,4 +107,43 @@ void main() {
channel.sink.addError("error");
expect(sinkController.stream.first, throwsA("error"));
});
+
+ test("Sink.done completes once the stream is done", () {
+ channel.stream.listen(null);
+ expect(channel.sink.done, completes);
+ streamController.close();
+ });
+
+ group("with allowSinkErrors: false", () {
+ setUp(() {
+ streamController = new StreamController();
+ sinkController = new StreamController();
+ channel = new StreamChannel.withGuarantees(
+ streamController.stream, sinkController.sink, allowSinkErrors: false);
+ });
+
+ test("forwards errors to Sink.done but not the stream", () {
+ channel.sink.addError("oh no");
+ expect(channel.sink.done, throwsA("oh no"));
+ sinkController.stream.listen(null, onError: expectAsync((_) {}, count: 0));
tjblasi 2016/02/04 23:16:01 line length (might just be Chromium Code Reviews U
+ });
+
+ test("adding an error causes the stream to emit a done event", () {
+ expect(channel.sink.done, throwsA("oh no"));
+
+ streamController.add(1);
+ streamController.add(2);
+ streamController.add(3);
+
+ expect(channel.stream.listen(expectAsync((event) {
+ if (event == 2) channel.sink.addError("oh no");
+ }, count: 2)).asFuture(), completes);
+ });
+
+ test("adding an error closes the inner sink", () {
+ channel.sink.addError("oh no");
+ expect(channel.sink.done, throwsA("oh no"));
+ expect(sinkController.stream.toList(), completion(isEmpty));
+ });
+ });
}
« lib/src/guarantee_channel.dart ('K') | « test/stream_channel_controller_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698