sort channels by stability upon running flutter channel (#48427)
This commit is contained in:
committed by
Flutter GitHub Bot
parent
10649ac42a
commit
a66e9569b5
@@ -46,6 +46,97 @@ void main() {
|
||||
await simpleChannelTest(<String>['channel', '-v']);
|
||||
});
|
||||
|
||||
testUsingContext('sorted by stability', () async {
|
||||
final Process processAll = createMockProcess(
|
||||
stdout: 'origin/beta\n'
|
||||
'origin/master\n'
|
||||
'origin/dev\n'
|
||||
'origin/stable\n');
|
||||
final Process processWithExtra = createMockProcess(
|
||||
stdout: 'origin/beta\n'
|
||||
'origin/master\n'
|
||||
'origin/dependabot/bundler\n'
|
||||
'origin/dev\n'
|
||||
'origin/v1.4.5-hotfixes\n'
|
||||
'origin/stable\n');
|
||||
final Process processWithMissing = createMockProcess(
|
||||
stdout: 'origin/beta\n'
|
||||
'origin/dependabot/bundler\n'
|
||||
'origin/v1.4.5-hotfixes\n'
|
||||
'origin/stable\n');
|
||||
|
||||
final ChannelCommand command = ChannelCommand();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(command);
|
||||
|
||||
when(mockProcessManager.start(
|
||||
<String>['git', 'branch', '-r'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenAnswer((_) => Future<Process>.value(processAll));
|
||||
await runner.run(<String>['channel']);
|
||||
verify(mockProcessManager.start(
|
||||
<String>['git', 'branch', '-r'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).called(1);
|
||||
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.substring(2)); // remove '* ' or ' ' from output
|
||||
expect(rows, containsAllInOrder(FlutterVersion.officialChannels));
|
||||
|
||||
// clear buffer for next process
|
||||
testLogger.clear();
|
||||
|
||||
when(mockProcessManager.start(
|
||||
<String>['git', 'branch', '-r'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenAnswer((_) => Future<Process>.value(processWithExtra));
|
||||
await runner.run(<String>['channel']);
|
||||
verify(mockProcessManager.start(
|
||||
<String>['git', 'branch', '-r'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).called(1);
|
||||
expect(testLogger.errorText, hasLength(0));
|
||||
// format the status text for a simpler assertion.
|
||||
final Iterable<String> rows2 = testLogger.statusText
|
||||
.split('\n')
|
||||
.map((String line) => line.substring(2)); // remove '* ' or ' ' from output
|
||||
expect(rows2, containsAllInOrder(FlutterVersion.officialChannels));
|
||||
|
||||
// clear buffer for next process
|
||||
testLogger.clear();
|
||||
|
||||
when(mockProcessManager.start(
|
||||
<String>['git', 'branch', '-r'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenAnswer((_) => Future<Process>.value(processWithMissing));
|
||||
await runner.run(<String>['channel']);
|
||||
verify(mockProcessManager.start(
|
||||
<String>['git', 'branch', '-r'],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).called(1);
|
||||
expect(testLogger.errorText, hasLength(0));
|
||||
// check if available official channels are in order of stability
|
||||
int prev = -1;
|
||||
int next = -1;
|
||||
for (final String branch in FlutterVersion.officialChannels) {
|
||||
next = testLogger.statusText.indexOf(branch);
|
||||
if (next != -1) {
|
||||
expect(prev < next, isTrue);
|
||||
prev = next;
|
||||
}
|
||||
}
|
||||
|
||||
}, overrides: <Type, Generator>{
|
||||
ProcessManager: () => mockProcessManager,
|
||||
});
|
||||
|
||||
testUsingContext('removes duplicates', () async {
|
||||
final Process process = createMockProcess(
|
||||
stdout: 'origin/dev\n'
|
||||
|
||||
Reference in New Issue
Block a user