Visitar URL original
Fix image_paver flaky test. (#138) · creatorpiyush/packages@8809ff0 · GitHub
Skip to content

Commit 8809ff0

Browse files
authored
Fix image_paver flaky test. (flutter#138)
* Fix image_paver tests flake. The flake was caused because the async pave method was call without an await. * Force the mock to return a future instead of null.
1 parent d92d97a commit 8809ff0

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

‎packages/fuchsia_ctl/test/image_paver_test.dart‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ void main() {
9191
tar = FakeTar(true, fs);
9292

9393
when(processManager.start(any)).thenAnswer((_) async {
94-
await Future<void>.delayed(const Duration(milliseconds: 3));
95-
return null;
94+
return Future<Process>.delayed(const Duration(milliseconds: 10), () {
95+
return FakeProcess(0, <String>['Good job'], <String>['']);
96+
});
9697
});
9798

9899
final ImagePaver paver = ImagePaver(
@@ -102,14 +103,16 @@ void main() {
102103
processManager: processManager,
103104
);
104105

105-
expect(
106-
paver.pave(
107-
'generic-x64.tgz',
108-
deviceName,
109-
verbose: false,
110-
timeoutMs: const Duration(milliseconds: 1),
111-
),
112-
throwsA(const TypeMatcher<TimeoutException>()));
106+
try {
107+
await paver.pave(
108+
'generic-x64.tgz',
109+
deviceName,
110+
verbose: false,
111+
timeoutMs: const Duration(milliseconds: 1),
112+
);
113+
} catch (e) {
114+
expect(e, isA<TimeoutException>());
115+
}
113116
});
114117

115118
test('Happy path', () async {

0 commit comments

Comments
 (0)