[flutter_tools] fix RangeError in flutter channel command (#103766)

This commit is contained in:
Christopher Fujino
2022-05-17 16:22:12 -07:00
committed by GitHub
parent 2ad7ced916
commit 0116b2e77d
2 changed files with 36 additions and 0 deletions

View File

@@ -136,6 +136,38 @@ void main() {
FileSystem: () => MemoryFileSystem.test(),
});
testUsingContext('ignores lines with unexpected output', () async {
fakeProcessManager.addCommand(
const FakeCommand(
command: <String>['git', 'branch', '-r'],
stdout: 'origin/beta\n'
'origin/stable\n'
'upstream/beta\n'
'upstream/stable\n'
'foo',
),
);
final ChannelCommand command = ChannelCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
await runner.run(<String>['channel']);
expect(fakeProcessManager.hasRemainingExpectations, isFalse);
expect(testLogger.errorText, hasLength(0));
// format the status text for a simpler assertion.
final Iterable<String> rows = testLogger.statusText
.split('\n')
.map((String line) => line.trim())
.where((String line) => line?.isNotEmpty == true)
.skip(1); // remove `Flutter channels:` line
expect(rows, <String>['beta', 'stable', 'Currently not on an official channel.']);
}, overrides: <Type, Generator>{
ProcessManager: () => fakeProcessManager,
FileSystem: () => MemoryFileSystem.test(),
});
testUsingContext('removes duplicates', () async {
fakeProcessManager.addCommand(
const FakeCommand(