diff --git a/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart b/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart index 7ab3bdb6e4e..b729add9392 100644 --- a/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart +++ b/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart @@ -13,30 +13,22 @@ import 'package:fuchsia_remote_debug_protocol/fuchsia_remote_debug_protocol.dart void main() { group('FuchsiaRemoteConnection.connect', () { MockSshCommandRunner mockRunner; + List forwardedPorts; + List mockPeerConnections; + List 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>.value( ['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 = []; int port = 0; - final List forwardedPorts = []; Future mockPortForwardingFunction( String address, int remotePort, [String interface = '', String configFile]) { @@ -91,8 +83,8 @@ void main() { }, ]; - final List mockPeerConnections = []; - final List uriConnections = []; + mockPeerConnections = []; + uriConnections = []; Future mockVmConnectionFunction(Uri uri) { return new Future(() 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 failingFunction() async { + await FuchsiaRemoteConnection.connect(); + } + + // Should fail as no env variable has been passed. + expect(failingFunction, + throwsA(const isInstanceOf())); + }); }); }