Skip to content

Commit 8f16d3e

Browse files
committed
test: add and improve e2e tests
1 parent 481c75b commit 8f16d3e

11 files changed

Lines changed: 92 additions & 10 deletions

File tree

e2e/helpers/command_helper.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void Function() withRunner(
3232
Logger logger,
3333
PubUpdater pubUpdater,
3434
List<String> printLogs,
35+
List<String> progressLogs,
3536
)
3637
runnerFn,
3738
) {
@@ -61,6 +62,12 @@ void Function() withRunner(
6162
() => pubUpdater.getLatestVersion(any()),
6263
).thenAnswer((_) => Future.value('1.0.0'));
6364

64-
await runnerFn(commandRunner, logger, pubUpdater, printLogs);
65+
await runnerFn(
66+
commandRunner,
67+
logger,
68+
pubUpdater,
69+
printLogs,
70+
progressLogs,
71+
);
6572
});
6673
}

e2e/test/commands/create/dart_cli/dart_cli_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void main() {
99
test(
1010
'create dart_cli',
1111
timeout: const Timeout(Duration(minutes: 2)),
12-
withRunner((commandRunner, logger, updater, logs) async {
12+
withRunner((commandRunner, logger, updater, logs, progressLogs) async {
1313
final tempDirectory = Directory.systemTemp.createTempSync();
1414
addTearDown(() => tempDirectory.deleteSync(recursive: true));
1515

e2e/test/commands/create/dart_package/dart_pkg_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void main() {
99
test(
1010
'create dart_package',
1111
timeout: const Timeout(Duration(minutes: 2)),
12-
withRunner((commandRunner, logger, updater, logs) async {
12+
withRunner((commandRunner, logger, updater, logs, progressLogs) async {
1313
final tempDirectory = Directory.systemTemp.createTempSync();
1414
addTearDown(() => tempDirectory.deleteSync(recursive: true));
1515

e2e/test/commands/create/docs_site/docs_site_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void main() {
99
test(
1010
'create docs_site',
1111
timeout: const Timeout(Duration(minutes: 2)),
12-
withRunner((commandRunner, logger, updater, logs) async {
12+
withRunner((commandRunner, logger, updater, logs, progressLogs) async {
1313
final tempDirectory = Directory.systemTemp.createTempSync();
1414
addTearDown(() => tempDirectory.deleteSync(recursive: true));
1515

e2e/test/commands/create/flame_game/flame_game_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void main() {
99
test(
1010
'create flame_game',
1111
timeout: const Timeout(Duration(minutes: 5)),
12-
withRunner((commandRunner, logger, updater, logs) async {
12+
withRunner((commandRunner, logger, updater, logs, progressLogs) async {
1313
final tempDirectory = Directory.systemTemp.createTempSync();
1414
addTearDown(() => tempDirectory.deleteSync(recursive: true));
1515

e2e/test/commands/create/flutter_app/core_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void main() {
99
test(
1010
'create flutter_app',
1111
timeout: const Timeout(Duration(minutes: 2)),
12-
withRunner((commandRunner, logger, updater, logs) async {
12+
withRunner((commandRunner, logger, updater, logs, progressLogs) async {
1313
final tempDirectory = Directory.systemTemp.createTempSync();
1414
addTearDown(() => tempDirectory.deleteSync(recursive: true));
1515

e2e/test/commands/create/flutter_package/flutter_pkg_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void main() {
99
test(
1010
'create flutter_package',
1111
timeout: const Timeout(Duration(minutes: 2)),
12-
withRunner((commandRunner, logger, updater, logs) async {
12+
withRunner((commandRunner, logger, updater, logs, progressLogs) async {
1313
final tempDirectory = Directory.systemTemp.createTempSync();
1414
addTearDown(() => tempDirectory.deleteSync(recursive: true));
1515

e2e/test/commands/create/flutter_plugin/flutter_plugin_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void main() {
99
test(
1010
'create flutter_plugin',
1111
timeout: const Timeout(Duration(minutes: 8)),
12-
withRunner((commandRunner, logger, updater, logs) async {
12+
withRunner((commandRunner, logger, updater, logs, progressLogs) async {
1313
final tempDirectory = Directory.systemTemp.createTempSync();
1414
addTearDown(() => tempDirectory.deleteSync(recursive: true));
1515

e2e/test/commands/packages/check/licenses/licenses_allowed_test.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void main() {
1515
test(
1616
'packages check licenses --allowed="MIT,BSD-3-Clause"',
1717
timeout: const Timeout(Duration(minutes: 2)),
18-
withRunner((commandRunner, logger, updater, logs) async {
18+
withRunner((commandRunner, logger, updater, logs, progressLogs) async {
1919
final tempDirectory = Directory.systemTemp.createTempSync();
2020
addTearDown(() => tempDirectory.deleteSync(recursive: true));
2121

@@ -52,6 +52,11 @@ void main() {
5252
equals(ExitCode.success.code),
5353
reason: 'Should succeed when allowed licenses are used',
5454
);
55+
56+
expect(
57+
progressLogs,
58+
contains('Retrieved 1 license from 1 package of type: MIT (1).'),
59+
);
5560
}),
5661
);
5762
}

e2e/test/commands/packages/check/licenses/licenses_forbidden_test.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'dart:io';
22

33
import 'package:mason/mason.dart';
4+
import 'package:mocktail/mocktail.dart';
45
import 'package:path/path.dart' as path;
56
import 'package:test/test.dart';
67

@@ -16,7 +17,7 @@ void main() {
1617
test(
1718
'packages check licenses --forbidden="MIT"',
1819
timeout: const Timeout(Duration(minutes: 2)),
19-
withRunner((commandRunner, logger, updater, logs) async {
20+
withRunner((commandRunner, logger, updater, logs, progressLogs) async {
2021
final tempDirectory = Directory.systemTemp.createTempSync();
2122
addTearDown(() => tempDirectory.deleteSync(recursive: true));
2223

@@ -54,6 +55,12 @@ void main() {
5455
equals(ExitCode.config.code),
5556
reason: 'Should fail when forbidden licenses are used',
5657
);
58+
59+
verify(
60+
() => logger.err(
61+
'1 dependency has a banned license: formz ([MIT](https://pub.dev/packages/formz/license)).',
62+
),
63+
).called(1);
5764
}),
5865
);
5966
}

0 commit comments

Comments
 (0)