mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
[flutter_tool] Some additional input validation for 'version' (#39136)
This commit is contained in:
parent
7f5540faac
commit
e9bd2ef087
|
@ -65,6 +65,10 @@ class VersionCommand extends FlutterCommand {
|
|||
|
||||
// check min supported version
|
||||
final Version targetVersion = Version.parse(version);
|
||||
if (targetVersion == null) {
|
||||
throwToolExit('Failed to parse version "$version"');
|
||||
}
|
||||
|
||||
bool withForce = false;
|
||||
if (targetVersion < minSupportedVersion) {
|
||||
if (!argResults['force']) {
|
||||
|
|
|
@ -62,6 +62,16 @@ void main() {
|
|||
ProcessManager: () => MockProcessManager(),
|
||||
});
|
||||
|
||||
testUsingContext('tool exit on confusing version', () async {
|
||||
const String version = 'master';
|
||||
final VersionCommand command = VersionCommand();
|
||||
final Future<void> runCommand = createTestCommandRunner(command).run(<String>['version', version]);
|
||||
expect(() async => await Future.wait<void>(<Future<void>>[runCommand]),
|
||||
throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
ProcessManager: () => MockProcessManager(),
|
||||
});
|
||||
|
||||
testUsingContext('exit tool if can\'t get the tags', () async {
|
||||
final VersionCommand command = VersionCommand();
|
||||
|
||||
|
|
Loading…
Reference in a new issue