[flutter_tools] Upgrade only from flutter update-packages (#103924)
This commit is contained in:
committed by
GitHub
parent
aa35c85e13
commit
586b15cbcb
@@ -12,6 +12,7 @@ import 'package:flutter_tools/src/commands/update_packages.dart';
|
||||
import 'package:flutter_tools/src/dart/pub.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:test/fake.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
@@ -173,6 +174,47 @@ void main() {
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
group('generateFakePubspec', () {
|
||||
const String prevVersion = '1.2.0';
|
||||
testUsingContext('constrains package versions to >= previous version if doUpgrade: true', () {
|
||||
final String pubspecSource = generateFakePubspec(
|
||||
<PubspecDependency>[
|
||||
PubspecDependency(
|
||||
' foo: $prevVersion',
|
||||
'foo',
|
||||
'',
|
||||
version: prevVersion,
|
||||
sourcePath: '/path/to/pubspec.yaml',
|
||||
kind: DependencyKind.normal,
|
||||
isTransitive: false,
|
||||
),
|
||||
],
|
||||
doUpgrade: true,
|
||||
);
|
||||
final YamlMap pubspec = loadYaml(pubspecSource) as YamlMap;
|
||||
expect((pubspec['dependencies'] as YamlMap)['foo'], '>= $prevVersion');
|
||||
});
|
||||
|
||||
testUsingContext('uses previous package versions doUpgrade: false', () {
|
||||
final String pubspecSource = generateFakePubspec(
|
||||
<PubspecDependency>[
|
||||
PubspecDependency(
|
||||
' foo: $prevVersion',
|
||||
'foo',
|
||||
'',
|
||||
version: prevVersion,
|
||||
sourcePath: '/path/to/pubspec.yaml',
|
||||
kind: DependencyKind.normal,
|
||||
isTransitive: false,
|
||||
),
|
||||
],
|
||||
doUpgrade: false,
|
||||
);
|
||||
final YamlMap pubspec = loadYaml(pubspecSource) as YamlMap;
|
||||
expect((pubspec['dependencies'] as YamlMap)['foo'], prevVersion);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class FakePub extends Fake implements Pub {
|
||||
|
||||
Reference in New Issue
Block a user