Skip to content

Commit 24382b6

Browse files
authored
Use drain to reach end of stream in tests (flutter#75)
Replace `.toList()` for cases where we don't care about the collected values. Replace `.listen(null).asFuture()` since that is exactly the implementation of `drain`.
1 parent 82692f9 commit 24382b6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/io_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void main() {
7575
server.transform(WebSocketTransformer()).listen((webSocket) {
7676
expect(() async {
7777
var channel = IOWebSocketChannel(webSocket);
78-
await channel.stream.listen(null).asFuture();
78+
await channel.stream.drain();
7979
expect(channel.closeCode, equals(5678));
8080
expect(channel.closeReason, equals("raisin"));
8181
}(), completes);
@@ -94,7 +94,7 @@ void main() {
9494
});
9595

9696
var channel = IOWebSocketChannel.connect("ws://localhost:${server.port}");
97-
expect(channel.stream.toList(),
97+
expect(channel.stream.drain(),
9898
throwsA(TypeMatcher<WebSocketChannelException>()));
9999
});
100100

@@ -111,7 +111,7 @@ void main() {
111111

112112
var channel = IOWebSocketChannel.connect("ws://localhost:${server.port}",
113113
protocols: [failedProtocol]);
114-
expect(channel.stream.toList(),
114+
expect(channel.stream.drain(),
115115
throwsA(TypeMatcher<WebSocketChannelException>()));
116116
});
117117

@@ -129,7 +129,7 @@ void main() {
129129

130130
var channel = IOWebSocketChannel.connect("ws://localhost:${server.port}",
131131
protocols: [passedProtocol]);
132-
await channel.stream.listen(null).asFuture();
132+
await channel.stream.drain();
133133
expect(channel.protocol, passedProtocol);
134134
});
135135
}

0 commit comments

Comments
 (0)