Unverified Commit 688948b7 authored by Prerak Mann's avatar Prerak Mann Committed by GitHub

switching channel prompts to run flutter upgrade (#49511)

parent b5f328e3
......@@ -116,7 +116,7 @@ class ChannelCommand extends FlutterCommand {
}
}
Future<void> _switchChannel(String branchName) {
Future<void> _switchChannel(String branchName) async {
globals.printStatus("Switching to flutter channel '$branchName'...");
if (FlutterVersion.obsoleteBranches.containsKey(branchName)) {
final String alternative = FlutterVersion.obsoleteBranches[branchName];
......@@ -124,7 +124,9 @@ class ChannelCommand extends FlutterCommand {
} else if (!FlutterVersion.officialChannels.contains(branchName)) {
globals.printStatus('This is not an official channel. For a list of available channels, try "flutter channel".');
}
return _checkout(branchName);
await _checkout(branchName);
globals.printStatus("Successfully switched to flutter channel '$branchName'.");
globals.printStatus("To ensure that you're on the latest build from this channel, run 'flutter upgrade'");
}
static Future<void> upgradeChannel() async {
......
......@@ -253,6 +253,51 @@ void main() {
ProcessManager: () => mockProcessManager,
});
testUsingContext('switching channels prompts to run flutter upgrade', () async {
when(mockProcessManager.start(
<String>['git', 'fetch'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).thenAnswer((_) => Future<Process>.value(createMockProcess()));
when(mockProcessManager.start(
<String>['git', 'show-ref', '--verify', '--quiet', 'refs/heads/beta'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).thenAnswer((_) => Future<Process>.value(createMockProcess()));
when(mockProcessManager.start(
<String>['git', 'checkout', 'beta', '--'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).thenAnswer((_) => Future<Process>.value(createMockProcess()));
final ChannelCommand command = ChannelCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
await runner.run(<String>['channel', 'beta']);
verify(mockProcessManager.start(
<String>['git', 'fetch'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).called(1);
verify(mockProcessManager.start(
<String>['git', 'show-ref', '--verify', '--quiet', 'refs/heads/beta'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).called(1);
verify(mockProcessManager.start(
<String>['git', 'checkout', 'beta', '--'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).called(1);
expect(testLogger.statusText, contains("Successfully switched to flutter channel 'beta'."));
expect(testLogger.statusText, contains("To ensure that you're on the latest build from this channel, run 'flutter upgrade'"));
expect(testLogger.errorText, hasLength(0));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => mockProcessManager,
});
// This verifies that bug https://github.com/flutter/flutter/issues/21134
// doesn't return.
testUsingContext('removes version stamp file when switching channels', () async {
......
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