mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[frdb] Added env test (#18485)
This commit is contained in:
parent
bb23a110e0
commit
0f2e50bb87
@ -13,30 +13,22 @@ import 'package:fuchsia_remote_debug_protocol/fuchsia_remote_debug_protocol.dart
|
||||
void main() {
|
||||
group('FuchsiaRemoteConnection.connect', () {
|
||||
MockSshCommandRunner mockRunner;
|
||||
List<MockPortForwarder> forwardedPorts;
|
||||
List<MockPeer> mockPeerConnections;
|
||||
List<Uri> uriConnections;
|
||||
|
||||
setUp(() {
|
||||
mockRunner = new MockSshCommandRunner();
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
/// Most tests will mock out the port forwarding and connection
|
||||
/// functions.
|
||||
restoreFuchsiaPortForwardingFunction();
|
||||
restoreVmServiceConnectionFunction();
|
||||
});
|
||||
|
||||
test('end-to-end with three vm connections and flutter view query',
|
||||
() async {
|
||||
const String address = 'fe80::8eae:4cff:fef4:9247';
|
||||
const String interface = 'eno1';
|
||||
// Adds some extra junk to make sure the strings will be cleaned up.
|
||||
when(mockRunner.run(typed(any))).thenAnswer((_) =>
|
||||
new Future<List<String>>.value(
|
||||
<String>['123\n\n\n', '456 ', '789']));
|
||||
const String address = 'fe80::8eae:4cff:fef4:9247';
|
||||
const String interface = 'eno1';
|
||||
when(mockRunner.address).thenReturn(address);
|
||||
when(mockRunner.interface).thenReturn(interface);
|
||||
forwardedPorts = <MockPortForwarder>[];
|
||||
int port = 0;
|
||||
final List<MockPortForwarder> forwardedPorts = <MockPortForwarder>[];
|
||||
Future<PortForwarder> mockPortForwardingFunction(
|
||||
String address, int remotePort,
|
||||
[String interface = '', String configFile]) {
|
||||
@ -91,8 +83,8 @@ void main() {
|
||||
},
|
||||
];
|
||||
|
||||
final List<MockPeer> mockPeerConnections = <MockPeer>[];
|
||||
final List<Uri> uriConnections = <Uri>[];
|
||||
mockPeerConnections = <MockPeer>[];
|
||||
uriConnections = <Uri>[];
|
||||
Future<json_rpc.Peer> mockVmConnectionFunction(Uri uri) {
|
||||
return new Future<json_rpc.Peer>(() async {
|
||||
final MockPeer mp = new MockPeer();
|
||||
@ -109,7 +101,17 @@ void main() {
|
||||
|
||||
fuchsiaPortForwardingFunction = mockPortForwardingFunction;
|
||||
fuchsiaVmServiceConnectionFunction = mockVmConnectionFunction;
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
/// Most tests will mock out the port forwarding and connection
|
||||
/// functions.
|
||||
restoreFuchsiaPortForwardingFunction();
|
||||
restoreVmServiceConnectionFunction();
|
||||
});
|
||||
|
||||
test('end-to-end with three vm connections and flutter view query',
|
||||
() async {
|
||||
final FuchsiaRemoteConnection connection =
|
||||
await FuchsiaRemoteConnection.connectWithSshCommandRunner(mockRunner);
|
||||
|
||||
@ -142,6 +144,16 @@ void main() {
|
||||
verify(forwardedPorts[1].stop());
|
||||
verify(forwardedPorts[2].stop());
|
||||
});
|
||||
|
||||
test('env variable test without remote addr', () async {
|
||||
Future<Null> failingFunction() async {
|
||||
await FuchsiaRemoteConnection.connect();
|
||||
}
|
||||
|
||||
// Should fail as no env variable has been passed.
|
||||
expect(failingFunction,
|
||||
throwsA(const isInstanceOf<FuchsiaRemoteConnectionError>()));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user