Open natebosch opened 5 months ago
cc @brianquinlan - are behavior differences expected from this type of refactoring? I would have hoped that the different fake implementations behave the same, and that wrapping a WebSocket
in an adapter should work the same as a WebSocketChannel
.
Opening this as the PR to have a place to see and discuss the differences.
I'm surprised that the tests fail. Are you seeing the failures locally because the github CI seems to get hung-up at the analysis phase.
Ah yeah, I had hoped to see the error on CI too, I'll fix up analysis and copy the logs in the meantime.
These stream matcher tests are unfortunately not very nice to debug so the log output isn't as useful as making changes in the test.
Let me patch this in and take a look.
The data seems to be flowing correctly but something is probably getting closed or not listed too early. The tests pass with this change
test('emmits a message to all listners', () async {
expect(clientChannel1.stream, emitsInOrder(['{}', emitsDone]));
expect(clientChannel2.stream, emitsInOrder(['{}', emitsDone]));
await createMockConnection(serverChannel1, 'web');
await createMockConnection(serverChannel2, 'web');
await handler.emitUpdateMessage(BuildResult(BuildStatus.success, []));
+ await Future.delayed(const Duration(seconds: 5));
await clientChannel1.sink.close();
await clientChannel2.sink.close();
});
The data gets received by the fake clientChannel1
/clientChannel2
and this line in adapter_web_socket_channel.dart
gets executed:
case TextDataReceived(text: final text):
_controller.local.sink.add(text);
But the data does not seem to appear in the _controller.foreign.stream
. StreamChannelController
is a bit hard to follow.
I'll play around with this some more next week. If the failure is only exposing some way that the test was too sensitive about async interleaving then I'm not too concerned about the difference impacting production use.
I added some await pumpEventQueue();
and it fixes most of the tests. I don't think this particular extra async event is anything that would impact production code (@jakemac53 let me know if you have any concerns about needing these test changes).
There is one remaining failure which I'll look at more tomorrow.
@jakemac53 let me know if you have any concerns about needing these test changes).
No concerns
Refactor serve_handler_test to use the
fakes
utility from theweb_socket
package instead of reimplement it locally.Currently this changes the behavior of the tests and they fail.