Skip to content

Commit 8c2c5fd

Browse files
committed
update integration tests
1 parent 44287e3 commit 8c2c5fd

File tree

4 files changed

+22
-29
lines changed

4 files changed

+22
-29
lines changed

analysis_options.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ analyzer:
66
exclude:
77
- "**.freezed.dart"
88
- "**.g.dart"
9-
errors:
10-
included_file_warning: ignore
119

1210
linter:
1311
rules:

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dev_dependencies:
3636
cider: ^0.1.5
3737
coverage: ^1.6.3
3838
custom_lint: ^0.3.4
39-
dart_test_tools: ^5.0.0
39+
dart_test_tools: ^5.0.1
4040
freezed: ^2.3.3
4141
json_serializable: ^6.6.2
4242
mocktail: ^0.3.0

test/integration/integration_test.dart

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ void main() {
8585
}) async {
8686
final knownTasks = [
8787
'format',
88-
'test-imports',
8988
'analyze',
89+
'custom-lint',
9090
'flutter-compat',
9191
'outdated',
9292
'pull-up-dependencies',
93-
'lib-exports',
93+
'osv-scanner',
9494
];
9595
final configEditor = YamlEditor('_placeholder: null');
9696
for (final task in knownTasks) {
@@ -146,9 +146,17 @@ dependencies:
146146
147147
dev_dependencies:
148148
lint: null
149+
custom_lint: null
150+
dart_test_tools: '>=5.0.0'
149151
''',
150152
);
151153

154+
await writeFile('analysis_options.yaml', '''
155+
analyzer:
156+
plugins:
157+
- custom_lint
158+
''');
159+
152160
await writeFile(
153161
'bin/format.dart',
154162
'''
@@ -285,40 +293,24 @@ void main() {
285293
);
286294
});
287295

288-
test('test-imports', () async {
296+
test('custom-lint', () async {
289297
final lines = <String>[];
290298
await git(const ['add', 'test/test.dart']);
291299
final code = await sut(
292-
'test-imports',
293-
arguments: const ['--detailed-exit-code', '-ldebug'],
294-
failOnError: false,
295-
onStdout: lines.add,
296-
);
297-
expect(code, HookResult.rejected.index);
298-
expect(
299-
lines,
300-
contains(
301-
startsWith(' [ERR] Found self import that is not from src: import '),
302-
),
303-
);
304-
});
305-
306-
test('lib-exports', () async {
307-
final lines = <String>[];
308-
await git(const ['add', 'lib']);
309-
final code = await sut(
310-
'lib-exports',
300+
'custom-lint',
311301
arguments: const ['--detailed-exit-code', '-ldebug'],
312302
failOnError: false,
313303
onStdout: lines.add,
314304
);
315305
expect(code, HookResult.rejected.index);
316306
expect(
317307
lines,
318-
contains(
319-
allOf(
320-
startsWith(' [ERR] '),
321-
endsWith('Source file is not exported anywhere'),
308+
allOf(
309+
contains(
310+
' [INF] lib/src/analyze.dart:1:6 • The library contains public symbols, but is not exported in any of the package library files. • src_library_not_exported',
311+
),
312+
contains(
313+
' [INF] test/test.dart:1:8 • Libraries in lib/src, test or tool should not import package library files from lib. • no_self_package_imports',
322314
),
323315
),
324316
);

test/unit/tasks/provider/default_tasks_loader_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:dart_pre_commit/src/config/pubspec_config_loader.dart';
22
import 'package:dart_pre_commit/src/tasks/analyze_task.dart';
3+
import 'package:dart_pre_commit/src/tasks/custom_lint_task.dart';
34
import 'package:dart_pre_commit/src/tasks/flutter_compat_task.dart';
45
import 'package:dart_pre_commit/src/tasks/format_task.dart';
56
import 'package:dart_pre_commit/src/tasks/osv_scanner_task.dart';
@@ -57,6 +58,7 @@ void main() {
5758
mockPubspecConfigLoader.loadPubspecConfig,
5859
() => mockTaskLoader.registerConfigurableTask(formatTaskProvider),
5960
() => mockTaskLoader.registerConfigurableTask(analyzeTaskProvider),
61+
() => mockTaskLoader.registerTask(customLintTaskProvider),
6062
() => mockTaskLoader.registerConfigurableTask(outdatedTaskProvider),
6163
() => mockTaskLoader
6264
.registerConfigurableTask(pullUpDependenciesTaskProvider),
@@ -78,6 +80,7 @@ void main() {
7880
mockPubspecConfigLoader.loadPubspecConfig,
7981
() => mockTaskLoader.registerConfigurableTask(formatTaskProvider),
8082
() => mockTaskLoader.registerConfigurableTask(analyzeTaskProvider),
83+
() => mockTaskLoader.registerTask(customLintTaskProvider),
8184
() => mockTaskLoader.registerTask(flutterCompatTaskProvider),
8285
() => mockTaskLoader.registerConfigurableTask(outdatedTaskProvider),
8386
() => mockTaskLoader

0 commit comments

Comments
 (0)