Unverified Commit 855b180e authored by Brian Quinlan's avatar Brian Quinlan Committed by GitHub

Remove FakeProcessResult for Dart 3 compatibility (#124240)

Removes code that `implements ProcessResult` since it will be `final` in
Dart 3.

Fixes https://github.com/flutter/flutter/issues/124237

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] All existing and new tests are passing.
parent ff6be43b
......@@ -34,12 +34,10 @@ void main() {
group('SshCommandRunner.run', () {
late FakeProcessManager fakeProcessManager;
late FakeProcessResult fakeProcessResult;
SshCommandRunner runner;
setUp(() {
fakeProcessResult = FakeProcessResult();
fakeProcessManager = FakeProcessManager()..fakeResult = fakeProcessResult;
fakeProcessManager = FakeProcessManager();
});
test('verify interface is appended to ipv6 address', () async {
......@@ -51,7 +49,7 @@ void main() {
interface: interface,
sshConfigPath: '/whatever',
);
fakeProcessResult.stdout = 'somestuff';
fakeProcessManager.fakeResult = ProcessResult(23, 0, 'somestuff', null);
await runner.run('ls /whatever');
expect(fakeProcessManager.runCommands.single, contains('$ipV6Addr%$interface'));
});
......@@ -62,7 +60,7 @@ void main() {
fakeProcessManager,
address: ipV6Addr,
);
fakeProcessResult.stdout = 'somestuff';
fakeProcessManager.fakeResult = ProcessResult(23, 0, 'somestuff', null);
await runner.run('ls /whatever');
expect(fakeProcessManager.runCommands.single, contains(ipV6Addr));
});
......@@ -71,11 +69,15 @@ void main() {
const String addr = '192.168.1.1';
runner = SshCommandRunner.withProcessManager(fakeProcessManager,
address: addr);
fakeProcessResult.stdout = '''
fakeProcessManager.fakeResult = ProcessResult(
23,
0,
'''
this
has
four
lines''';
lines''',
null);
final List<String> result = await runner.run('oihaw');
expect(result, hasLength(4));
});
......@@ -84,8 +86,7 @@ void main() {
const String addr = '192.168.1.1';
runner = SshCommandRunner.withProcessManager(fakeProcessManager,
address: addr);
fakeProcessResult.stdout = 'whatever';
fakeProcessResult.exitCode = 1;
fakeProcessManager.fakeResult = ProcessResult(23, 1, 'whatever', null);
Future<void> failingFunction() async {
await runner.run('oihaw');
}
......@@ -101,7 +102,7 @@ void main() {
address: addr,
sshConfigPath: config,
);
fakeProcessResult.stdout = 'somestuff';
fakeProcessManager.fakeResult = ProcessResult(23, 0, 'somestuff', null);
await runner.run('ls /whatever');
final List<String?> passedCommand = fakeProcessManager.runCommands.single as List<String?>;
expect(passedCommand, contains('-F'));
......@@ -116,7 +117,7 @@ void main() {
fakeProcessManager,
address: addr,
);
fakeProcessResult.stdout = 'somestuff';
fakeProcessManager.fakeResult = ProcessResult(23, 0, 'somestuff', null);
await runner.run('ls /whatever');
final List<String?> passedCommand = fakeProcessManager.runCommands.single as List<String?>;
final int indexOfFlag = passedCommand.indexOf('-F');
......@@ -126,7 +127,7 @@ void main() {
}
class FakeProcessManager extends Fake implements ProcessManager {
FakeProcessResult? fakeResult;
ProcessResult? fakeResult;
List<List<dynamic>> runCommands = <List<dynamic>>[];
......@@ -143,14 +144,3 @@ class FakeProcessManager extends Fake implements ProcessManager {
return fakeResult!;
}
}
class FakeProcessResult extends Fake implements ProcessResult {
@override
int exitCode = 0;
@override
dynamic stdout;
@override
dynamic stderr;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment