Unverified Commit 0f2e50bb authored by Andrew Davies's avatar Andrew Davies Committed by GitHub

[frdb] Added env test (#18485)

parent bb23a110
...@@ -13,30 +13,22 @@ import 'package:fuchsia_remote_debug_protocol/fuchsia_remote_debug_protocol.dart ...@@ -13,30 +13,22 @@ import 'package:fuchsia_remote_debug_protocol/fuchsia_remote_debug_protocol.dart
void main() { void main() {
group('FuchsiaRemoteConnection.connect', () { group('FuchsiaRemoteConnection.connect', () {
MockSshCommandRunner mockRunner; MockSshCommandRunner mockRunner;
List<MockPortForwarder> forwardedPorts;
List<MockPeer> mockPeerConnections;
List<Uri> uriConnections;
setUp(() { setUp(() {
mockRunner = new MockSshCommandRunner(); 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. // Adds some extra junk to make sure the strings will be cleaned up.
when(mockRunner.run(typed(any))).thenAnswer((_) => when(mockRunner.run(typed(any))).thenAnswer((_) =>
new Future<List<String>>.value( new Future<List<String>>.value(
<String>['123\n\n\n', '456 ', '789'])); <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.address).thenReturn(address);
when(mockRunner.interface).thenReturn(interface); when(mockRunner.interface).thenReturn(interface);
forwardedPorts = <MockPortForwarder>[];
int port = 0; int port = 0;
final List<MockPortForwarder> forwardedPorts = <MockPortForwarder>[];
Future<PortForwarder> mockPortForwardingFunction( Future<PortForwarder> mockPortForwardingFunction(
String address, int remotePort, String address, int remotePort,
[String interface = '', String configFile]) { [String interface = '', String configFile]) {
...@@ -91,8 +83,8 @@ void main() { ...@@ -91,8 +83,8 @@ void main() {
}, },
]; ];
final List<MockPeer> mockPeerConnections = <MockPeer>[]; mockPeerConnections = <MockPeer>[];
final List<Uri> uriConnections = <Uri>[]; uriConnections = <Uri>[];
Future<json_rpc.Peer> mockVmConnectionFunction(Uri uri) { Future<json_rpc.Peer> mockVmConnectionFunction(Uri uri) {
return new Future<json_rpc.Peer>(() async { return new Future<json_rpc.Peer>(() async {
final MockPeer mp = new MockPeer(); final MockPeer mp = new MockPeer();
...@@ -109,7 +101,17 @@ void main() { ...@@ -109,7 +101,17 @@ void main() {
fuchsiaPortForwardingFunction = mockPortForwardingFunction; fuchsiaPortForwardingFunction = mockPortForwardingFunction;
fuchsiaVmServiceConnectionFunction = mockVmConnectionFunction; 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 = final FuchsiaRemoteConnection connection =
await FuchsiaRemoteConnection.connectWithSshCommandRunner(mockRunner); await FuchsiaRemoteConnection.connectWithSshCommandRunner(mockRunner);
...@@ -142,6 +144,16 @@ void main() { ...@@ -142,6 +144,16 @@ void main() {
verify(forwardedPorts[1].stop()); verify(forwardedPorts[1].stop());
verify(forwardedPorts[2].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>()));
});
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment