Visitar URL original
Fix tests failing with timeouts. (#162) · flutter/packages@5f3e639 · GitHub
Skip to content

Commit 5f3e639

Browse files
authored
Fix tests failing with timeouts. (#162)
This is because expect is not waiting properly for the async methods to complete.
1 parent 1dc5165 commit 5f3e639

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

‎packages/fuchsia_ctl/test/ssh_client_test.dart‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void main() {
8989
expect(args.last, 'ls -al');
9090
});
9191

92-
test('sshCommand times out', () {
92+
test('sshCommand times out', () async {
9393
final MockProcessManager processManager = MockProcessManager();
9494

9595
when(processManager.run(any)).thenAnswer((_) async {
@@ -98,14 +98,16 @@ void main() {
9898
});
9999

100100
final SshClient ssh = SshClient(processManager: processManager);
101-
expect(
102-
ssh.runCommand(
103-
targetIp,
104-
identityFilePath: identityFilePath,
105-
command: const <String>['ls', '-al'],
106-
timeoutMs: const Duration(milliseconds: 1),
107-
),
108-
throwsA(const TypeMatcher<TimeoutException>()));
101+
try {
102+
await ssh.runCommand(
103+
targetIp,
104+
identityFilePath: identityFilePath,
105+
command: const <String>['ls', '-al'],
106+
timeoutMs: const Duration(milliseconds: 1),
107+
);
108+
} catch (e) {
109+
expect(e, isA<TimeoutException>());
110+
}
109111
});
110112
}
111113

‎packages/fuchsia_ctl/test/tar_test.dart‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ void main() {
2121
});
2222

2323
final Tar tar = SystemTar(processManager: processManager);
24-
expect(
25-
tar.untar(
26-
'source.tar',
27-
'/destination',
28-
timeoutMs: const Duration(milliseconds: 1),
29-
),
30-
throwsA(const TypeMatcher<TimeoutException>()));
24+
try {
25+
await tar.untar(
26+
'source.tar',
27+
'/destination',
28+
timeoutMs: const Duration(milliseconds: 1),
29+
);
30+
} catch (e) {
31+
expect(e, isA<TimeoutException>());
32+
}
3133
});
3234
});
3335
}

0 commit comments

Comments
 (0)