Skip to content

Commit 0e63104

Browse files
authored
fix: allow spaced golden file names (#722)
* chore: very_good create * refactor: moved test e2e tests * refactor: moved e2e create commands * refactor: removed e2e tag * ci: configured e2e ci * chore: removed README.md * ci: removed tag * chore: removed --set-exit-if-changed * ci: ammends e2e workflow * test: tested spaced golden file name * fix: allow golden spaced test names
1 parent c3564ac commit 0e63104

File tree

7 files changed

+70
-2
lines changed

7 files changed

+70
-2
lines changed

.github/workflows/e2e.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
# E2E tests for the test command
3333
- test/commands/test/async_main/async_main_test.dart
3434
- test/commands/test/no_project/no_project_test.dart
35+
- test/commands/test/spaced_golden_file_name/spaced_golden_file_name_test.dart
3536

3637
# E2E tests for the create command
3738
- test/commands/create/flutter_app/core_test.dart

bricks/test_optimizer/__brick__/test/.test_optimizer.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: spaced_golden_file_name
2+
description: Fixture for testing golden files with spaced file names.
3+
publish_to: none
4+
5+
environment:
6+
sdk: ">=2.18.0 <3.0.0"
7+
8+
dependencies:
9+
flutter:
10+
sdk: flutter
11+
12+
dev_dependencies:
13+
flutter_test:
14+
sdk: flutter
16.5 KB
Loading
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
4+
void main() {
5+
testWidgets('renders SizedBox', (tester) async {
6+
final widget = SizedBox.shrink();
7+
await tester.pumpWidget(widget);
8+
9+
await expectLater(
10+
find.byWidget(widget),
11+
matchesGoldenFile('sized box.png'),
12+
);
13+
});
14+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import 'package:mason/mason.dart';
2+
import 'package:mocktail/mocktail.dart';
3+
import 'package:test/test.dart';
4+
import 'package:universal_io/io.dart';
5+
6+
import '../../../../helpers/helpers.dart';
7+
8+
void main() {
9+
test(
10+
'allows golden files with spaces in the name',
11+
timeout: const Timeout(Duration(minutes: 2)),
12+
withRunner((commandRunner, logger, updater, logs) async {
13+
final tempDirectory = Directory.systemTemp.createTempSync('async_main');
14+
addTearDown(() => tempDirectory.deleteSync(recursive: true));
15+
16+
await copyDirectory(
17+
Directory('test/commands/test/spaced_golden_file_name/fixture'),
18+
tempDirectory,
19+
);
20+
21+
await expectSuccessfulProcessResult(
22+
'flutter',
23+
['pub', 'get'],
24+
workingDirectory: tempDirectory.path,
25+
);
26+
await expectSuccessfulProcessResult(
27+
'flutter',
28+
['test', '--update-goldens'],
29+
workingDirectory: tempDirectory.path,
30+
);
31+
32+
Directory.current = tempDirectory;
33+
final result = await commandRunner.run(['test']);
34+
35+
verifyNever(() => logger.err(any()));
36+
expect(result, equals(ExitCode.success.code));
37+
}),
38+
);
39+
}

lib/src/commands/test/templates/test_optimizer_bundle.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)