use mokito in the init tests
This commit is contained in:
parent
ab441685e2
commit
e6b45c5023
@ -65,13 +65,10 @@ Or if the Sky APK is not already on your device, run:
|
|||||||
stdout.addStream(process.stdout);
|
stdout.addStream(process.stdout);
|
||||||
stderr.addStream(process.stderr);
|
stderr.addStream(process.stderr);
|
||||||
int code = await process.exitCode;
|
int code = await process.exitCode;
|
||||||
if (code == 0) {
|
if (code != 0) return code;
|
||||||
print('\n${message}');
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
print(message);
|
print(message);
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,6 +143,7 @@ name: {{projectName}}
|
|||||||
description: {{description}}
|
description: {{description}}
|
||||||
dependencies:
|
dependencies:
|
||||||
sky: any
|
sky: any
|
||||||
|
dev_dependencies:
|
||||||
sky_tools: any
|
sky_tools: any
|
||||||
''';
|
''';
|
||||||
|
|
||||||
|
@ -4,11 +4,13 @@
|
|||||||
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:args/args.dart';
|
import 'package:mockito/mockito.dart';
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:sky_tools/src/init.dart';
|
import 'package:sky_tools/src/init.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
import 'src/common.dart';
|
||||||
|
|
||||||
main() => defineTests();
|
main() => defineTests();
|
||||||
|
|
||||||
defineTests() {
|
defineTests() {
|
||||||
@ -26,10 +28,11 @@ defineTests() {
|
|||||||
// Verify that we create a project that is well-formed.
|
// Verify that we create a project that is well-formed.
|
||||||
test('init sky-simple', () async {
|
test('init sky-simple', () async {
|
||||||
InitCommandHandler handler = new InitCommandHandler();
|
InitCommandHandler handler = new InitCommandHandler();
|
||||||
_MockArgResults results = new _MockArgResults();
|
MockArgResults results = new MockArgResults();
|
||||||
results.values['help'] = false;
|
when(results['help']).thenReturn(false);
|
||||||
results.values['pub'] = true;
|
when(results['pub']).thenReturn(true);
|
||||||
results.values['out'] = temp.path;
|
when(results.wasParsed('out')).thenReturn(true);
|
||||||
|
when(results['out']).thenReturn(temp.path);
|
||||||
await handler.processArgResults(results);
|
await handler.processArgResults(results);
|
||||||
String path = p.join(temp.path, 'lib/main.dart');
|
String path = p.join(temp.path, 'lib/main.dart');
|
||||||
expect(new File(path).existsSync(), true);
|
expect(new File(path).existsSync(), true);
|
||||||
@ -40,14 +43,3 @@ defineTests() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MockArgResults implements ArgResults {
|
|
||||||
Map values = {};
|
|
||||||
operator [](String name) => values[name];
|
|
||||||
List<String> get arguments => null;
|
|
||||||
ArgResults get command => null;
|
|
||||||
String get name => null;
|
|
||||||
Iterable<String> get options => values.keys;
|
|
||||||
List<String> get rest => null;
|
|
||||||
bool wasParsed(String name) => values.containsKey(name);
|
|
||||||
}
|
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
|
|
||||||
library install_test;
|
library install_test;
|
||||||
|
|
||||||
import 'package:args/args.dart';
|
|
||||||
import 'package:mockito/mockito.dart';
|
import 'package:mockito/mockito.dart';
|
||||||
import 'package:sky_tools/src/install.dart';
|
import 'package:sky_tools/src/install.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
import 'src/common.dart';
|
||||||
|
|
||||||
main() => defineTests();
|
main() => defineTests();
|
||||||
|
|
||||||
defineTests() {
|
defineTests() {
|
||||||
@ -23,9 +24,3 @@ defineTests() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@proxy
|
|
||||||
class MockArgResults extends Mock implements ArgResults {
|
|
||||||
@override
|
|
||||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
|
||||||
}
|
|
||||||
|
12
packages/flutter_tools/test/src/common.dart
Normal file
12
packages/flutter_tools/test/src/common.dart
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'package:args/args.dart';
|
||||||
|
import 'package:mockito/mockito.dart';
|
||||||
|
|
||||||
|
@proxy
|
||||||
|
class MockArgResults extends Mock implements ArgResults {
|
||||||
|
@override
|
||||||
|
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user