Leave a version tag when creating project (#12846)

* Leave a version tag when creating project

* Generalize .version to .metadata
This commit is contained in:
xster
2017-11-03 10:07:57 -07:00
committed by GitHub
parent b865b0eb2f
commit c17099f474
3 changed files with 32 additions and 0 deletions

View File

@@ -12,15 +12,21 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/create.dart';
import 'package:flutter_tools/src/dart/sdk.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart';
import 'package:test/test.dart';
import '../src/common.dart';
import '../src/context.dart';
const String frameworkRevision = '12345678';
const String frameworkChannel = 'omega';
void main() {
group('create', () {
Directory temp;
Directory projectDir;
FlutterVersion mockFlutterVersion;
setUpAll(() {
Cache.disableLocking();
@@ -29,6 +35,7 @@ void main() {
setUp(() {
temp = fs.systemTempDirectory.createTempSync('flutter_tools');
projectDir = temp.childDirectory('flutter_project');
mockFlutterVersion = new MockFlutterVersion();
});
tearDown(() {
@@ -171,6 +178,8 @@ void main() {
// Verify content and formatting
testUsingContext('content', () async {
Cache.flutterRoot = '../..';
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
final CreateCommand command = new CreateCommand();
final CommandRunner<Null> runner = createTestCommandRunner(command);
@@ -229,6 +238,16 @@ void main() {
final File xcodeProjectFile = fs.file(fs.path.join(projectDir.path, xcodeProjectPath));
final String xcodeProject = xcodeProjectFile.readAsStringSync();
expect(xcodeProject, contains('PRODUCT_BUNDLE_IDENTIFIER = com.foo.bar.flutterProject'));
final String versionPath = fs.path.join('.metadata');
expectExists(versionPath);
final String version = fs.file(fs.path.join(projectDir.path, versionPath)).readAsStringSync();
expect(version, contains('version:'));
expect(version, contains('revision: 12345678'));
expect(version, contains('channel: omega'));
},
overrides: <Type, Generator>{
FlutterVersion: () => mockFlutterVersion,
});
// Verify that we can regenerate over an existing project.
@@ -334,3 +353,5 @@ Future<Null> _analyzeProject(String workingDir, {String target}) async {
}
expect(exec.exitCode, 0);
}
class MockFlutterVersion extends Mock implements FlutterVersion {}