Skip to content

Commit

Permalink
Coverage is restricted by vm
Browse files Browse the repository at this point in the history
  • Loading branch information
git-elliot committed Mar 31, 2024
1 parent 1881e9a commit 4c9bed9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
7 changes: 3 additions & 4 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,9 @@ packages:
network_tools:
dependency: transitive
description:
name: network_tools
sha256: cf5726a3c3edd82de5f6d6511cb618259a083225ccc2bdb8a55d87b37014cadf
url: "https://pub.dev"
source: hosted
path: "../../network_tools"
relative: true
source: path
version: "5.0.2"
network_tools_flutter:
dependency: "direct main"
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ dependencies:
logging: ^1.2.0
# Deal with internationalized/localized messages and more.
intl: ^0.18.0
network_tools: ^5.0.0
network_tools:
path: ../network_tools
path_provider: ^2.1.1
universal_io: ^2.2.2
nsd: ^2.3.1
Expand Down
8 changes: 6 additions & 2 deletions test/host_scan_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ void main() {
// Fetching interfaceIp and hostIp
setUpAll(() async {
HttpOverrides.global = FakeResponseHttpOverrides();
await configureNetworkToolsFlutter('build');
// Use implementation classes to call methods to increase coverage
await configureNetworkToolsFlutter('build', enableDebugging: true);
hostScannerService =
HostScannerService.instance as HostScannerServiceFlutterImpl;

Expand All @@ -36,13 +35,18 @@ void main() {
// Better to restrict to scan from hostId - 1 to hostId + 1 to prevent GHA timeouts
firstHostId = hostId <= 1 ? hostId : hostId - 1;
lastHostId = hostId >= 254 ? hostId : hostId + 1;
logger.fine("First hostId : $firstHostId and last hostId : $lastHostId");
logger.fine(
'Fetched own host as $myOwnHost and interface address as $interfaceIp',
);
}
});

group('Testing Host Scanner emits', () {
test('Check if flutter implementations are injected', () {
expect(
HostScannerService.instance is HostScannerServiceFlutterImpl, true);
});
test('Running getAllPingableDevices emits tests', () async* {
expectLater(
//There should be at least one device pingable in network
Expand Down
6 changes: 5 additions & 1 deletion test/port_scan_flutter_test.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'dart:async';

import 'package:flutter_test/flutter_test.dart';
import 'package:network_tools_flutter/network_tools_flutter.dart';
import 'package:network_tools_flutter/src/services_impls/port_scanner_service_flutter_impl.dart';
import 'fake_http_overrides.dart';
import 'package:universal_io/io.dart';
import 'package:network_tools_flutter/network_tools_flutter.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
Expand Down Expand Up @@ -35,6 +35,10 @@ void main() {
});

group('Testing Port Scanner', () {
test('Check if flutter implementations are injected', () {
expect(
PortScannerService.instance is PortScannerServiceFlutterImpl, true);
});
test('Running scanPortsForSingleDevice tests', () {
for (final activeHost in hostsWithOpenPort) {
final port = activeHost.openPorts.elementAt(0).port;
Expand Down

0 comments on commit 4c9bed9

Please sign in to comment.