@@ -71,6 +71,28 @@ void main() {
71
71
FlutterVersion : () => mockVersion,
72
72
});
73
73
74
+ testUsingContext ('dev version switch prompt is accepted' , () async {
75
+ when (mockStdio.stdinHasTerminal).thenReturn (true );
76
+ const String version = '30.0.0-dev.0.0' ;
77
+ final VersionCommand command = VersionCommand ();
78
+ when (globals.terminal.promptForCharInput (< String > ['y' , 'n' ],
79
+ logger: anyNamed ('logger' ),
80
+ prompt: 'Are you sure you want to proceed?' )
81
+ ).thenAnswer ((Invocation invocation) async => 'y' );
82
+
83
+ await createTestCommandRunner (command).run (< String > [
84
+ 'version' ,
85
+ '--no-pub' ,
86
+ version,
87
+ ]);
88
+ expect (testLogger.statusText, contains ('Switching Flutter to version $version ' ));
89
+ }, overrides: < Type , Generator > {
90
+ ProcessManager : () => MockProcessManager (),
91
+ Stdio : () => mockStdio,
92
+ AnsiTerminal : () => MockTerminal (),
93
+ FlutterVersion : () => mockVersion,
94
+ });
95
+
74
96
testUsingContext ('version switch prompt is declined' , () async {
75
97
when (mockStdio.stdinHasTerminal).thenReturn (true );
76
98
const String version = '10.0.0' ;
@@ -239,7 +261,7 @@ class MockProcessManager extends Mock implements ProcessManager {
239
261
return ProcessResult (0 , 0 , 'v10.0.0\r\n v20.0.0\r\n 30.0.0-dev.0.0' , '' );
240
262
}
241
263
if (command[0 ] == 'git' && command[1 ] == 'checkout' ) {
242
- version = (command[2 ] as String ).replaceFirst ('v' , '' );
264
+ version = (command[2 ] as String ).replaceFirst (RegExp ( '^v' ) , '' );
243
265
}
244
266
return ProcessResult (0 , 0 , '' , '' );
245
267
}
0 commit comments