Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to web_socket_channel 3.0.0 #462

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion links/gql_websocket_link/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ dependencies:
meta: ^1.3.0
rxdart: '>=0.26.0 <0.28.0'
uuid: '>=3.0.0 <5.0.0'
web_socket_channel: ^2.0.0
web_socket_channel: ^3.0.0
web_socket: ^0.1.5
dev_dependencies:
gql_pedantic: ^1.0.2
mockito: ^5.0.0
Expand Down
51 changes: 35 additions & 16 deletions links/gql_websocket_link/test/gql_websocket_link_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ void _testLinks(
link = makeLink(null, channelGenerator: () => channel);
//
link.request(request).listen(print);

await server.close();
},
);

Expand Down Expand Up @@ -204,6 +206,8 @@ void _testLinks(
);
//
link.request(request).listen(print);

await server.close();
},
);

Expand Down Expand Up @@ -254,6 +258,8 @@ void _testLinks(
);
//
link.request(request).listen(print);

await server.close();
},
);

Expand Down Expand Up @@ -341,6 +347,8 @@ void _testLinks(
},
),
);

await server.close();
},
);

Expand Down Expand Up @@ -465,6 +473,8 @@ void _testLinks(
count: maxCall,
),
);

await server.close();
},
);

Expand Down Expand Up @@ -567,6 +577,8 @@ void _testLinks(
},
),
);

await server.close();
},
);

Expand Down Expand Up @@ -703,6 +715,8 @@ void _testLinks(
count: maxCall,
),
);

await server.close();
},
);

Expand Down Expand Up @@ -757,6 +771,7 @@ void _testLinks(
webSocket = await WebSocket.connect("ws://localhost:${server.port}");
channel = IOWebSocketChannel(webSocket);
link = makeLink(null, channelGenerator: () => channel);
await server.close();
expect(
link.request(request).first,
throwsA(isA<WebSocketLinkParserException>()),
Expand Down Expand Up @@ -812,6 +827,7 @@ void _testLinks(
webSocket = await WebSocket.connect("ws://localhost:${server.port}");
channel = IOWebSocketChannel(webSocket);
link = makeLink(null, channelGenerator: () => channel);
await server.close();
expect(
link.request(request).first,
throwsA(isA<WebSocketLinkServerException>()),
Expand All @@ -822,7 +838,7 @@ void _testLinks(
HttpServer server;
WebSocket webSocket;
IOWebSocketChannel channel;
Link link;
late Link link;
Request request;

request = Request(
Expand All @@ -836,10 +852,16 @@ void _testLinks(
server.transform(WebSocketTransformer());

webSocket = await WebSocket.connect("ws://localhost:${server.port}");
// Close the socket to cause network error.
await webSocket.close();
channel = IOWebSocketChannel(webSocket);
link = makeLink(null, channelGenerator: () => channel);
channel.stream.listen(null, onError: (err) {});

await webSocket.close();
link = makeLink(
null,
channelGenerator: () => channel,
autoReconnect: false,
);
await server.close();
expect(
link.request(request).first,
throwsA(isA<WebSocketLinkServerException>()),
Expand Down Expand Up @@ -908,6 +930,8 @@ void _testLinks(
channel = IOWebSocketChannel(webSocket);
link = makeLink(null, channelGenerator: () => channel);
responseSub = link.request(request).listen(print);

await server.close();
});

test(
Expand Down Expand Up @@ -1065,7 +1089,7 @@ void _testLinks(
ConnectionAck(),
),
);
webSocket.close(websocket_status.goingAway);
webSocket.close(websocket_status.normalClosure);
}
messageCount++;
},
Expand All @@ -1079,16 +1103,11 @@ void _testLinks(
),
);

link = makeLink(
null,
channelGenerator: () async {
final webSocket =
await WebSocket.connect("ws://localhost:${server.port}");
return IOWebSocketChannel(webSocket);
},
reconnectInterval: Duration(milliseconds: 500),
);
//
link = makeLink(null, channelGenerator: () async {
final webSocket =
await WebSocket.connect("ws://localhost:${server.port}");
return IOWebSocketChannel(webSocket);
}, reconnectInterval: Duration(milliseconds: 500), autoReconnect: true);
link.request(request).listen(print, onError: print);
},
);
Expand Down Expand Up @@ -1137,7 +1156,7 @@ void _testLinks(
expect(map["type"], startMessageType);
subId = map["id"] as String?;
// disconnect
webSocket.close(websocket_status.goingAway);
webSocket.close(websocket_status.normalClosure);
}
messageCount++;
},
Expand Down
Loading