smoke test VM service connection before returning VMService object (#12914)

This commit is contained in:
Yegor
2017-11-08 10:43:47 -08:00
committed by GitHub
parent e1cbbc1c18
commit d4830fcf1b
6 changed files with 39 additions and 14 deletions

View File

@@ -0,0 +1,21 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:web_socket_channel/web_socket_channel.dart';
import 'package:test/test.dart';
import 'package:flutter_tools/src/base/port_scanner.dart';
import 'package:flutter_tools/src/vmservice.dart';
void main() {
group('VMService', () {
test('fails connection eagerly in the connect() method', () async {
final int port = await const HostPortScanner().findAvailablePort();
expect(
VMService.connect(Uri.parse('http://localhost:$port')),
throwsA(const isInstanceOf<WebSocketChannelException>()),
);
});
});
}